(t *testing.T)
| 139 | } |
| 140 | |
| 141 | func TestFieldsListRemove(t *testing.T) { |
| 142 | testFieldsList := core.NewFieldsList( |
| 143 | &core.TextField{Id: "id1", Name: "test1"}, |
| 144 | &core.TextField{Id: "id2", Name: "test2"}, |
| 145 | &core.TextField{Id: "id3", Name: "test3"}, |
| 146 | &core.TextField{Id: "id4", Name: "test4"}, |
| 147 | &core.TextField{Id: "id5", Name: "test5"}, |
| 148 | &core.TextField{Id: "id6", Name: "test6"}, |
| 149 | ) |
| 150 | |
| 151 | // remove by id |
| 152 | testFieldsList.RemoveById("id2") |
| 153 | testFieldsList.RemoveById("test3") // should do nothing |
| 154 | |
| 155 | // remove by name |
| 156 | testFieldsList.RemoveByName("test5") |
| 157 | testFieldsList.RemoveByName("id6") // should do nothing |
| 158 | |
| 159 | expected := []string{"test1", "test3", "test4", "test6"} |
| 160 | |
| 161 | if len(testFieldsList) != len(expected) { |
| 162 | t.Fatalf("Expected %d, got %d\n%v", len(expected), len(testFieldsList), testFieldsList) |
| 163 | } |
| 164 | |
| 165 | for _, name := range expected { |
| 166 | if f := testFieldsList.GetByName(name); f == nil { |
| 167 | t.Fatalf("Missing field %q", name) |
| 168 | } |
| 169 | } |
| 170 | } |
| 171 | |
| 172 | func TestFieldsListAdd(t *testing.T) { |
| 173 | f0 := &core.TextField{} |
nothing calls this directly
no test coverage detected
searching dependent graphs…