(t *testing.T, ctx context.Context, s *UsersStore)
| 844 | } |
| 845 | |
| 846 | func usersIsUsernameUsed(t *testing.T, ctx context.Context, s *UsersStore) { |
| 847 | alice, err := s.Create(ctx, "alice", "alice@example.com", CreateUserOptions{}) |
| 848 | require.NoError(t, err) |
| 849 | |
| 850 | tests := []struct { |
| 851 | name string |
| 852 | username string |
| 853 | excludeUserID int64 |
| 854 | want bool |
| 855 | }{ |
| 856 | { |
| 857 | name: "no change", |
| 858 | username: alice.Name, |
| 859 | excludeUserID: alice.ID, |
| 860 | want: false, |
| 861 | }, |
| 862 | { |
| 863 | name: "change case", |
| 864 | username: strings.ToUpper(alice.Name), |
| 865 | excludeUserID: alice.ID, |
| 866 | want: false, |
| 867 | }, |
| 868 | { |
| 869 | name: "not used", |
| 870 | username: "bob", |
| 871 | excludeUserID: alice.ID, |
| 872 | want: false, |
| 873 | }, |
| 874 | { |
| 875 | name: "not used when not excluded", |
| 876 | username: "bob", |
| 877 | excludeUserID: 0, |
| 878 | want: false, |
| 879 | }, |
| 880 | |
| 881 | { |
| 882 | name: "used when not excluded", |
| 883 | username: alice.Name, |
| 884 | excludeUserID: 0, |
| 885 | want: true, |
| 886 | }, |
| 887 | } |
| 888 | for _, test := range tests { |
| 889 | t.Run(test.name, func(t *testing.T) { |
| 890 | got := s.IsUsernameUsed(ctx, test.username, test.excludeUserID) |
| 891 | assert.Equal(t, test.want, got) |
| 892 | }) |
| 893 | } |
| 894 | } |
| 895 | |
| 896 | func usersList(t *testing.T, ctx context.Context, s *UsersStore) { |
| 897 | alice, err := s.Create(ctx, "alice", "alice@example.com", CreateUserOptions{}) |
nothing calls this directly
no test coverage detected