MCPcopy Create free account
hub / github.com/canopyclimate/golive / expectValuesAndChanges

Function expectValuesAndChanges

changeset/changeset_test.go:125–143  ·  view source on GitHub ↗
(cs *Changeset[T], expectMatch bool, t *testing.T)

Source from the content-addressed store, hash-verified

123}
124
125func expectValuesAndChanges[T any](cs *Changeset[T], expectMatch bool, t *testing.T) {
126 diffLength := len(cs.Changes) != len(cs.Values)
127 if expectMatch && diffLength {
128 t.Errorf("Expected Changes and Values match=%v, got %d and %d", expectMatch, len(cs.Changes), len(cs.Values))
129 }
130 if !expectMatch && !diffLength {
131 t.Errorf("Expected Changes and Values match=%v, got %d and %d", expectMatch, len(cs.Changes), len(cs.Values))
132 }
133 for k, v := range cs.Changes {
134 if expectMatch && len(v) != len(cs.Values[k]) {
135 t.Errorf("Expected Changes to have same number of entries, got %v", cs.Changes)
136 }
137 for i, s := range v {
138 if s != cs.Values[k][i] {
139 t.Errorf("Expected matching entries for key %s, got %s and %s", k, s, cs.Values[k][i])
140 }
141 }
142 }
143}
144
145func TestChangesOnEmptyInit(t *testing.T) {
146 cs := New[Person](&cc, nil)

Callers 2

TestChangesOnEmptyInitFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected