(t *testing.T)
| 13 | ) |
| 14 | |
| 15 | func TestNewFactory(t *testing.T) { |
| 16 | t.Run("creates factory with empty extras", func(t *testing.T) { |
| 17 | enabled := map[provisioning.RepositoryType]struct{}{} |
| 18 | factory, err := ProvideFactory(enabled, []Extra{}) |
| 19 | |
| 20 | require.NoError(t, err) |
| 21 | require.NotNil(t, factory) |
| 22 | types := factory.Types() |
| 23 | assert.Empty(t, types) |
| 24 | }) |
| 25 | |
| 26 | t.Run("creates factory with multiple extras", func(t *testing.T) { |
| 27 | localExtra := &MockExtra{} |
| 28 | localExtra.On("Type").Return(provisioning.LocalRepositoryType) |
| 29 | |
| 30 | gitExtra := &MockExtra{} |
| 31 | gitExtra.On("Type").Return(provisioning.GitRepositoryType) |
| 32 | |
| 33 | githubExtra := &MockExtra{} |
| 34 | githubExtra.On("Type").Return(provisioning.GitHubRepositoryType) |
| 35 | |
| 36 | enabled := map[provisioning.RepositoryType]struct{}{ |
| 37 | provisioning.LocalRepositoryType: {}, |
| 38 | provisioning.GitRepositoryType: {}, |
| 39 | provisioning.GitHubRepositoryType: {}, |
| 40 | } |
| 41 | extras := []Extra{localExtra, gitExtra, githubExtra} |
| 42 | factory, err := ProvideFactory(enabled, extras) |
| 43 | |
| 44 | require.NoError(t, err) |
| 45 | require.NotNil(t, factory) |
| 46 | types := factory.Types() |
| 47 | assert.Len(t, types, 3) |
| 48 | |
| 49 | // Verify stable ordering - types should be sorted alphabetically |
| 50 | expectedTypes := []provisioning.RepositoryType{ |
| 51 | provisioning.GitRepositoryType, |
| 52 | provisioning.GitHubRepositoryType, |
| 53 | provisioning.LocalRepositoryType, |
| 54 | } |
| 55 | assert.Equal(t, expectedTypes, types) |
| 56 | |
| 57 | localExtra.AssertExpectations(t) |
| 58 | gitExtra.AssertExpectations(t) |
| 59 | githubExtra.AssertExpectations(t) |
| 60 | }) |
| 61 | |
| 62 | t.Run("returns error for duplicate repository types", func(t *testing.T) { |
| 63 | firstExtra := &MockExtra{} |
| 64 | firstExtra.On("Type").Return(provisioning.LocalRepositoryType) |
| 65 | |
| 66 | secondExtra := &MockExtra{} |
| 67 | secondExtra.On("Type").Return(provisioning.LocalRepositoryType) |
| 68 | |
| 69 | enabled := map[provisioning.RepositoryType]struct{}{ |
| 70 | provisioning.LocalRepositoryType: {}, |
| 71 | } |
| 72 | extras := []Extra{firstExtra, secondExtra} |
nothing calls this directly
no test coverage detected