sdk/command_test.go

46 lines
1.1 KiB
Go
Raw Permalink Normal View History

2024-07-21 10:15:55 +00:00
package sdk
import "testing"
func TestCommandProperties_String(t *testing.T) {
t.Parallel()
props := CommandProperties{"hello": "world"}
if got, want := props.String(), "hello=world"; got != want {
t.Errorf("expected %q to be %q", got, want)
}
props["foo"] = "bar"
if got, want := props.String(), "foo=bar,hello=world"; got != want {
t.Errorf("expected %q to be %q", got, want)
}
}
func TestCommand_String(t *testing.T) {
t.Parallel()
cmd := Command{Name: "foo"}
if got, want := cmd.String(), "::foo::"; got != want {
t.Errorf("expected %q to be %q", got, want)
}
cmd = Command{Name: "foo", Message: "bar"}
if got, want := cmd.String(), "::foo::bar"; got != want {
t.Errorf("expected %q to be %q", got, want)
}
cmd = Command{
Name: "foo",
Message: "bar",
Properties: CommandProperties{"bar": "foo"},
}
if got, want := cmd.String(), "::foo bar=foo::bar"; got != want {
t.Errorf("expected %q to be %q", got, want)
}
cmd = Command{Message: "quux"}
if got, want := cmd.String(), "::missing.command::quux"; got != want {
t.Errorf("expected %q to be %q", got, want)
}
}