(t *testing.T)
| 142 | } |
| 143 | |
| 144 | func TestValidateEnvironmentsColor(t *testing.T) { |
| 145 | service := &SettingService{} |
| 146 | env := func(color *colorpb.Color) *v1pb.EnvironmentSetting_Environment { |
| 147 | return &v1pb.EnvironmentSetting_Environment{ |
| 148 | Id: "test", |
| 149 | Title: "Test", |
| 150 | Color: color, |
| 151 | } |
| 152 | } |
| 153 | cases := []struct { |
| 154 | name string |
| 155 | color *colorpb.Color |
| 156 | wantErr bool |
| 157 | }{ |
| 158 | {"nil ok", nil, false}, |
| 159 | {"valid", colorValue(0.31, 0.27, 0.9), false}, |
| 160 | {"red below range rejected", colorValue(-0.1, 0.27, 0.9), true}, |
| 161 | {"green above range rejected", colorValue(0.31, 1.1, 0.9), true}, |
| 162 | {"alpha below one rejected", colorWithAlpha(0.31, 0.27, 0.9, 0.5), true}, |
| 163 | } |
| 164 | for _, tc := range cases { |
| 165 | t.Run(tc.name, func(t *testing.T) { |
| 166 | err := service.validateEnvironments(context.Background(), "workspaces/default", []*v1pb.EnvironmentSetting_Environment{env(tc.color)}) |
| 167 | if tc.wantErr { |
| 168 | require.Error(t, err) |
| 169 | } else { |
| 170 | require.NoError(t, err) |
| 171 | } |
| 172 | }) |
| 173 | } |
| 174 | } |
nothing calls this directly
no test coverage detected