mirror of
https://github.com/eosswedenorg/thalos
synced 2026-07-04 12:03:41 +02:00
api/channel.go: adding TableDelta channel
This commit is contained in:
parent
a55367844e
commit
8dbf411b36
2 changed files with 33 additions and 0 deletions
|
|
@ -66,3 +66,18 @@ func (a ActionChannel) Channel() Channel {
|
||||||
|
|
||||||
return ch
|
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
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -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)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue