test simple string parameter
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Adrien Marquès 2020-03-01 21:34:14 +01:00
parent 22947db2b6
commit 77dbc5663b
Signed by: xdrm-brackets
GPG Key ID: D75243CA236D825E
1 changed files with 58 additions and 0 deletions

View File

@ -0,0 +1,58 @@
package reqdata
import (
"testing"
)
func TestSimpleString(t *testing.T) {
p := Parameter{Parsed: false, File: false, Value: "some-string"}
err := p.Parse()
if err != nil {
t.Errorf("unexpected error: <%s>", err)
t.FailNow()
}
if !p.Parsed {
t.Errorf("expected parameter to be parsed")
t.FailNow()
}
cast, canCast := p.Value.(string)
if !canCast {
t.Errorf("expected parameter to be a string")
t.FailNow()
}
if cast != "some-string" {
t.Errorf("expected parameter to equal 'some-string', got '%s'", cast)
t.FailNow()
}
}
func TestStringSlice(t *testing.T) {
p := Parameter{Parsed: false, File: false, Value: "some-string"}
err := p.Parse()
if err != nil {
t.Errorf("unexpected error: <%s>", err)
t.FailNow()
}
if !p.Parsed {
t.Errorf("expected parameter to be parsed")
t.FailNow()
}
cast, canCast := p.Value.(string)
if !canCast {
t.Errorf("expected parameter to be a string")
t.FailNow()
}
if cast != "some-string" {
t.Errorf("expected parameter to equal 'some-string', got '%s'", cast)
t.FailNow()
}
}