62 lines
1.1 KiB
Go
62 lines
1.1 KiB
Go
package thestore_test
|
|
|
|
import (
|
|
"render231011/internal/thestore"
|
|
"testing"
|
|
)
|
|
|
|
func TestEventMerging(t *testing.T) {
|
|
cases := map[string]struct {
|
|
base thestore.Event
|
|
operation thestore.Event
|
|
want thestore.Event
|
|
}{
|
|
"noop on noop": {},
|
|
"add to nothing": {
|
|
base: thestore.Event{
|
|
ID: "x",
|
|
},
|
|
operation: thestore.Event{
|
|
ID: "x",
|
|
Region: "newregion",
|
|
Status: "newstatus",
|
|
URL: "newurl",
|
|
},
|
|
want: thestore.Event{
|
|
ID: "x",
|
|
Region: "newregion",
|
|
Status: "newstatus",
|
|
URL: "newurl",
|
|
},
|
|
},
|
|
"change region": {
|
|
base: thestore.Event{
|
|
ID: "x",
|
|
Region: "region",
|
|
Status: "status",
|
|
URL: "url",
|
|
},
|
|
operation: thestore.Event{
|
|
ID: "x",
|
|
Region: "newregion",
|
|
},
|
|
want: thestore.Event{
|
|
ID: "x",
|
|
Region: "newregion",
|
|
Status: "status",
|
|
URL: "url",
|
|
},
|
|
},
|
|
}
|
|
|
|
for name, d := range cases {
|
|
c := d
|
|
t.Run(name, func(t *testing.T) {
|
|
got := c.base.Push(c.operation)
|
|
if got != c.want {
|
|
t.Errorf("wanted \n\t%+v, got\n\t%+v", c.want, got)
|
|
}
|
|
})
|
|
}
|
|
}
|