Skip to content

Commit

Permalink
feat: Add tests for segment feature flag in deploy.go
Browse files Browse the repository at this point in the history
  • Loading branch information
tomazpu committed Jan 10, 2025
1 parent 2177563 commit 45559e8
Showing 1 changed file with 54 additions and 0 deletions.
54 changes: 54 additions & 0 deletions pkg/deploy/deploy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package deploy_test
import (
"context"
"fmt"
"github.com/dynatrace/dynatrace-configuration-as-code/v2/internal/featureflags"
"testing"

"github.com/stretchr/testify/assert"
Expand Down Expand Up @@ -1298,3 +1299,56 @@ func TestDeployConfigGraph_CollectsAllErrors(t *testing.T) {
})

}

func TestDeployConfigFF(t *testing.T) {
dummyClientSet := client.DummyClientSet
c := dynatrace.EnvironmentClients{
dynatrace.EnvironmentInfo{Name: "env"}: &dummyClientSet,
}
tests := []struct {
name string
projects []project.Project
featureFlag string
configType config.TypeID
expectedErrString string
}{
{
name: "segments FF test",
projects: []project.Project{
{
Configs: project.ConfigsPerTypePerEnvironments{
"env": project.ConfigsPerType{
"p1": {
config.Config{
Type: config.Segment{},
Environment: "env",
Coordinate: coordinate.Coordinate{
Project: "p1",
Type: "type",
ConfigId: "config1",
},
},
},
},
},
},
},
featureFlag: featureflags.Segments.EnvName(),
configType: config.SegmentID,
},
}

for _, tt := range tests {
t.Run(tt.name+" | FF Enabled", func(t *testing.T) {
t.Setenv(tt.featureFlag, "true")
err := deploy.Deploy(context.TODO(), tt.projects, c, deploy.DeployConfigsOptions{})
//Dummy client returns unimplemented error on every execution of any method
assert.Errorf(t, err, "unimplemented")
})
t.Run(tt.name+" | FF Disabled", func(t *testing.T) {
t.Setenv(tt.featureFlag, "false")
err := deploy.Deploy(context.TODO(), tt.projects, c, deploy.DeployConfigsOptions{})
assert.Errorf(t, err, fmt.Sprintf("unknown config-type (ID: %q)", tt.configType))
})
}
}

0 comments on commit 45559e8

Please sign in to comment.