TestApplyGroupDifference is mainly testing the database functions
(t *testing.T)
| 449 | |
| 450 | // TestApplyGroupDifference is mainly testing the database functions |
| 451 | func TestApplyGroupDifference(t *testing.T) { |
| 452 | t.Parallel() |
| 453 | |
| 454 | ids := coderdtest.NewDeterministicUUIDGenerator() |
| 455 | testCase := []struct { |
| 456 | Name string |
| 457 | Before map[uuid.UUID]bool |
| 458 | Add []uuid.UUID |
| 459 | Remove []uuid.UUID |
| 460 | Expect []uuid.UUID |
| 461 | }{ |
| 462 | { |
| 463 | Name: "Empty", |
| 464 | }, |
| 465 | { |
| 466 | Name: "AddFromNone", |
| 467 | Before: map[uuid.UUID]bool{ |
| 468 | ids.ID("g1"): false, |
| 469 | }, |
| 470 | Add: []uuid.UUID{ |
| 471 | ids.ID("g1"), |
| 472 | }, |
| 473 | Expect: []uuid.UUID{ |
| 474 | ids.ID("g1"), |
| 475 | }, |
| 476 | }, |
| 477 | { |
| 478 | Name: "AddSome", |
| 479 | Before: map[uuid.UUID]bool{ |
| 480 | ids.ID("g1"): true, |
| 481 | ids.ID("g2"): false, |
| 482 | ids.ID("g3"): false, |
| 483 | uuid.New(): false, |
| 484 | }, |
| 485 | Add: []uuid.UUID{ |
| 486 | ids.ID("g2"), |
| 487 | ids.ID("g3"), |
| 488 | }, |
| 489 | Expect: []uuid.UUID{ |
| 490 | ids.ID("g1"), |
| 491 | ids.ID("g2"), |
| 492 | ids.ID("g3"), |
| 493 | }, |
| 494 | }, |
| 495 | { |
| 496 | Name: "RemoveAll", |
| 497 | Before: map[uuid.UUID]bool{ |
| 498 | uuid.New(): false, |
| 499 | ids.ID("g2"): true, |
| 500 | ids.ID("g3"): true, |
| 501 | }, |
| 502 | Remove: []uuid.UUID{ |
| 503 | ids.ID("g2"), |
| 504 | ids.ID("g3"), |
| 505 | }, |
| 506 | Expect: []uuid.UUID{}, |
| 507 | }, |
| 508 | { |
nothing calls this directly
no test coverage detected