1
0
Fork 0
mirror of https://github.com/eosswedenorg/thalos synced 2026-06-16 04:24:56 +02:00

api/channel.go: adding TableDelta channel

This commit is contained in:
Henrik Hautakoski 2024-01-07 19:11:47 +01:00
parent a55367844e
commit 8dbf411b36
2 changed files with 33 additions and 0 deletions

View file

@ -66,3 +66,18 @@ func (a ActionChannel) Channel() Channel {
return ch
}
// Table deltas
type TableDeltaChannel struct {
Name string
}
func (td TableDeltaChannel) Channel() Channel {
ch := Channel{"tabledeltas"}
if len(td.Name) > 0 {
ch.Append("name", td.Name)
}
return ch
}

View file

@ -129,3 +129,21 @@ func TestAction_Channel(t *testing.T) {
})
}
}
func TestTableDelta_Channel(t *testing.T) {
tests := []struct {
name string
action TableDeltaChannel
want Channel
}{
{"Empty", TableDeltaChannel{}, Channel{"tabledeltas"}},
{"Contract", TableDeltaChannel{Name: "delta_name"}, Channel{"tabledeltas", "name", "delta_name"}},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := tt.action.Channel(); !got.Is(tt.want) {
t.Errorf("TableDeltaChannel.String() = %v, want %v", got, tt.want)
}
})
}
}