github.com/databricks/cli@v0.203.0/bundle/config/mutator/default_environment_test.go (about) 1 package mutator_test 2 3 import ( 4 "context" 5 "testing" 6 7 "github.com/databricks/cli/bundle" 8 "github.com/databricks/cli/bundle/config" 9 "github.com/databricks/cli/bundle/config/mutator" 10 "github.com/stretchr/testify/assert" 11 "github.com/stretchr/testify/require" 12 ) 13 14 func TestDefaultEnvironment(t *testing.T) { 15 bundle := &bundle.Bundle{} 16 err := mutator.DefineDefaultEnvironment().Apply(context.Background(), bundle) 17 require.NoError(t, err) 18 env, ok := bundle.Config.Environments["default"] 19 assert.True(t, ok) 20 assert.Equal(t, &config.Environment{}, env) 21 } 22 23 func TestDefaultEnvironmentAlreadySpecified(t *testing.T) { 24 bundle := &bundle.Bundle{ 25 Config: config.Root{ 26 Environments: map[string]*config.Environment{ 27 "development": {}, 28 }, 29 }, 30 } 31 err := mutator.DefineDefaultEnvironment().Apply(context.Background(), bundle) 32 require.NoError(t, err) 33 _, ok := bundle.Config.Environments["default"] 34 assert.False(t, ok) 35 }