(t *testing.T)
| 126 | } |
| 127 | |
| 128 | func TestCollectionSpecMapReplacements(t *testing.T) { |
| 129 | cs := &CollectionSpec{ |
| 130 | Maps: map[string]*MapSpec{ |
| 131 | "test-map": { |
| 132 | Type: Array, |
| 133 | KeySize: 4, |
| 134 | ValueSize: 4, |
| 135 | MaxEntries: 1, |
| 136 | }, |
| 137 | }, |
| 138 | Programs: map[string]*ProgramSpec{ |
| 139 | "test-prog": loadKeyFromMapProgramSpec.Copy(), |
| 140 | }, |
| 141 | } |
| 142 | |
| 143 | // Replace the map with another one |
| 144 | newMap := mustNewMap(t, cs.Maps["test-map"], nil) |
| 145 | |
| 146 | err := newMap.Put(uint32(0), uint32(2)) |
| 147 | if err != nil { |
| 148 | t.Fatal(err) |
| 149 | } |
| 150 | |
| 151 | coll := mustNewCollection(t, cs, &CollectionOptions{ |
| 152 | MapReplacements: map[string]*Map{ |
| 153 | "test-map": newMap, |
| 154 | }, |
| 155 | }) |
| 156 | |
| 157 | ret := mustRun(t, coll.Programs["test-prog"], nil) |
| 158 | |
| 159 | if ret != 2 { |
| 160 | t.Fatal("new / override map not used") |
| 161 | } |
| 162 | |
| 163 | // Check that newMap isn't closed when the collection is closed |
| 164 | coll.Close() |
| 165 | err = newMap.Put(uint32(0), uint32(3)) |
| 166 | if err != nil { |
| 167 | t.Fatalf("failed to update replaced map: %s", err) |
| 168 | } |
| 169 | } |
| 170 | |
| 171 | func TestCollectionSpecMapReplacements_NonExistingMap(t *testing.T) { |
| 172 | cs := &CollectionSpec{ |
nothing calls this directly
no test coverage detected
searching dependent graphs…