Skip to content

Commit

Permalink
fix: manglet feilhåndering i tester
Browse files Browse the repository at this point in the history
  • Loading branch information
Kyrremann committed Feb 28, 2022
1 parent 6a00345 commit e25dea4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
9 changes: 6 additions & 3 deletions pkg/config/kafka_environment_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package config

import (
"github.com/nais/cli/pkg/aiven"
"github.com/nais/cli/pkg/consts"
"github.com/nais/cli/pkg/test"
"github.com/stretchr/testify/assert"
Expand All @@ -22,7 +23,8 @@ func TestKafkaEnvironmentConfigGenerated(t *testing.T) {
}

tmpDest := test.SetupDest(t)
kcatConfig := NewEnvConfig(test.SetupSecret(envKeys), tmpDest)
kcatConfig, err := NewEnvConfig(test.SetupSecret(envKeys), tmpDest, aiven.Kafka)
assert.NoError(t, err)

result, err := kcatConfig.Generate()
assert.NoError(t, err)
Expand Down Expand Up @@ -50,8 +52,9 @@ func TestKafkaEnvironmentSecrettMissingRequiredData(t *testing.T) {
}

tmpDest := test.SetupDest(t)
kcatConfig := NewEnvConfig(test.SetupSecret(envKeys), tmpDest)
_, err := kcatConfig.Generate()
kcatConfig, err := NewEnvConfig(test.SetupSecret(envKeys), tmpDest, aiven.Kafka)
assert.NoError(t, err)
_, err = kcatConfig.Generate()
assert.EqualError(t, err, "can not generate kafka-secret.env config, secret missing required key: client.truststore.jks")

defer os.Remove(tmpDest)
Expand Down
7 changes: 5 additions & 2 deletions pkg/secret/secret.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,11 @@ func (s *Secret) CreateKCatConfig() error {
}

func (s *Secret) CreateEnvConfig() error {
kafkaEnv := config.NewEnvConfig(s.Secret, s.DestinationPath, s.Service)
_, err := kafkaEnv.Generate()
kafkaEnv, err := config.NewEnvConfig(s.Secret, s.DestinationPath, s.Service)
if err != nil {
return err
}
_, err = kafkaEnv.Generate()
if err != nil {
return fmt.Errorf("generate %s config-type", s.ConfigType)
}
Expand Down

0 comments on commit e25dea4

Please sign in to comment.