(t *testing.T)
| 209 | } |
| 210 | |
| 211 | func TestVerifyUniqueWithinMutationBoundsChecks(t *testing.T) { |
| 212 | t.Run("gmuIndex out of bounds", func(t *testing.T) { |
| 213 | qc := &queryContext{ |
| 214 | gmuList: []*dql.Mutation{ |
| 215 | { |
| 216 | Set: []*api.NQuad{ |
| 217 | { |
| 218 | Subject: "_:a", |
| 219 | Predicate: "username", |
| 220 | ObjectValue: &api.Value{ |
| 221 | Val: &api.Value_StrVal{StrVal: "user1"}, |
| 222 | }, |
| 223 | }, |
| 224 | }, |
| 225 | }, |
| 226 | }, |
| 227 | // Reference gmuList[1], which is out of bounds. |
| 228 | uniqueVars: map[uint64]uniquePredMeta{ |
| 229 | encodeIndex(1, 0): {}, |
| 230 | }, |
| 231 | } |
| 232 | err := verifyUniqueWithinMutation(qc) |
| 233 | require.NoError(t, err) |
| 234 | }) |
| 235 | |
| 236 | t.Run("rdfIndex out of bounds", func(t *testing.T) { |
| 237 | qc := &queryContext{ |
| 238 | gmuList: []*dql.Mutation{ |
| 239 | { |
| 240 | Set: []*api.NQuad{ |
| 241 | // Only one element at index 0. |
| 242 | { |
| 243 | Subject: "_:a", |
| 244 | Predicate: "username", |
| 245 | ObjectValue: &api.Value{ |
| 246 | Val: &api.Value_StrVal{StrVal: "user1"}, |
| 247 | }, |
| 248 | }, |
| 249 | }, |
| 250 | }, |
| 251 | }, |
| 252 | // Reference Set[1], which is out of bounds. |
| 253 | uniqueVars: map[uint64]uniquePredMeta{ |
| 254 | encodeIndex(0, 1): {}, |
| 255 | }, |
| 256 | } |
| 257 | err := verifyUniqueWithinMutation(qc) |
| 258 | require.NoError(t, err) |
| 259 | }) |
| 260 | |
| 261 | t.Run("gmuList element is nil", func(t *testing.T) { |
| 262 | qc := &queryContext{ |
| 263 | gmuList: []*dql.Mutation{ |
| 264 | nil, // Element at index 0 is nil. |
| 265 | }, |
| 266 | uniqueVars: map[uint64]uniquePredMeta{ |
| 267 | encodeIndex(0, 0): {}, |
| 268 | }, |
nothing calls this directly
no test coverage detected