@@ -4,18 +4,16 @@ import (
44 "context"
55 "testing"
66
7- "k8s.io/apimachinery/pkg/api/resource"
8-
9- sagemakerConfig "github.com/flyteorg/flyteplugins/go/tasks/plugins/k8s/sagemaker/config"
10-
11- "github.com/flyteorg/flytestdlib/config"
12- "github.com/flyteorg/flytestdlib/config/viper"
137 "github.com/stretchr/testify/assert"
148 v1 "k8s.io/api/core/v1"
9+ "k8s.io/apimachinery/pkg/api/resource"
1510
1611 "github.com/flyteorg/flyteplugins/go/tasks/logs"
1712 flyteK8sConfig "github.com/flyteorg/flyteplugins/go/tasks/pluginmachinery/flytek8s/config"
13+ sagemakerConfig "github.com/flyteorg/flyteplugins/go/tasks/plugins/k8s/sagemaker/config"
1814 "github.com/flyteorg/flyteplugins/go/tasks/plugins/k8s/spark"
15+ "github.com/flyteorg/flytestdlib/config"
16+ "github.com/flyteorg/flytestdlib/config/viper"
1917)
2018
2119func TestLoadConfig (t * testing.T ) {
@@ -26,7 +24,6 @@ func TestLoadConfig(t *testing.T) {
2624
2725 err := configAccessor .UpdateConfig (context .TODO ())
2826 assert .NoError (t , err )
29-
3027 t .Run ("k8s-config-test" , func (t * testing.T ) {
3128
3229 k8sConfig := flyteK8sConfig .GetK8sPluginConfig ()
@@ -127,3 +124,27 @@ func TestLoadConfig(t *testing.T) {
127124 assert .NotNil (t , sagemakerConfig .GetSagemakerConfig ())
128125 })
129126}
127+
128+ func TestLoadIncorrectConfig (t * testing.T ) {
129+ t .Run ("logs-config-test-accept-bad-config" , func (t * testing.T ) {
130+ configAccessor := viper .NewAccessor (config.Options {
131+ StrictMode : false ,
132+ SearchPaths : []string {"testdata/incorrect-config.yaml" },
133+ })
134+
135+ err := configAccessor .UpdateConfig (context .TODO ())
136+ assert .NoError (t , err )
137+ assert .NotNil (t , logs .GetLogConfig ())
138+ assert .True (t , logs .GetLogConfig ().IsKubernetesEnabled )
139+ })
140+
141+ t .Run ("logs-config-test-failfast" , func (t * testing.T ) {
142+ configAccessor := viper .NewAccessor (config.Options {
143+ StrictMode : true ,
144+ SearchPaths : []string {"testdata/incorrect-config.yaml" },
145+ })
146+
147+ err := configAccessor .UpdateConfig (context .TODO ())
148+ assert .Error (t , err )
149+ })
150+ }
0 commit comments