From 98878eb12734c560c2e611c16f01c91f66f2244a Mon Sep 17 00:00:00 2001 From: xdrm-brackets Date: Sun, 1 Mar 2020 21:34:14 +0100 Subject: [PATCH] test simple string parameter --- internal/reqdata/parameter_test.go | 58 ++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 internal/reqdata/parameter_test.go diff --git a/internal/reqdata/parameter_test.go b/internal/reqdata/parameter_test.go new file mode 100644 index 0000000..f63f33e --- /dev/null +++ b/internal/reqdata/parameter_test.go @@ -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() + } +}