feat: add initial helper methods

This commit is contained in:
Louis Seubert 2024-07-21 12:15:55 +02:00
commit 76a93c0d8c
Signed by: louis9902
GPG key ID: 4B9DB28F826553BD
6 changed files with 1165 additions and 0 deletions

45
command_test.go Normal file
View file

@ -0,0 +1,45 @@
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)
}
}