@@ -5,23 +5,28 @@ import (
55 "testing"
66
77 "github.com/databricks/cli/libs/cmdio"
8+ "github.com/databricks/cli/libs/dbr"
89 "github.com/stretchr/testify/assert"
910 "github.com/stretchr/testify/require"
1011)
1112
13+ func testContext (t * testing.T ) context.Context {
14+ return dbr .DetectRuntime (context .Background ())
15+ }
16+
1217func TestTemplateResolverBothTagAndBranch (t * testing.T ) {
1318 r := Resolver {
1419 Tag : "tag" ,
1520 Branch : "branch" ,
1621 }
1722
18- _ , err := r .Resolve (context . Background ( ))
23+ _ , err := r .Resolve (testContext ( t ))
1924 assert .EqualError (t , err , "only one of tag or branch can be specified" )
2025}
2126
2227func TestTemplateResolverErrorsWhenPromptingIsNotSupported (t * testing.T ) {
2328 r := Resolver {}
24- ctx := cmdio .MockDiscard (context . Background ( ))
29+ ctx := cmdio .MockDiscard (testContext ( t ))
2530
2631 _ , err := r .Resolve (ctx )
2732 assert .EqualError (t , err , "prompting is not supported. Please specify the path, name or URL of the template to use" )
@@ -38,7 +43,7 @@ func TestTemplateResolverForDefaultTemplates(t *testing.T) {
3843 TemplatePathOrUrl : name ,
3944 }
4045
41- tmpl , err := r .Resolve (context . Background ( ))
46+ tmpl , err := r .Resolve (testContext ( t ))
4247 require .NoError (t , err )
4348
4449 assert .Equal (t , & builtinReader {name : name }, tmpl .Reader )
@@ -52,7 +57,7 @@ func TestTemplateResolverForDefaultTemplates(t *testing.T) {
5257 ConfigFile : "/config/file" ,
5358 }
5459
55- tmpl , err := r .Resolve (context . Background ( ))
60+ tmpl , err := r .Resolve (testContext ( t ))
5661 require .NoError (t , err )
5762
5863 // Assert reader and writer configuration
@@ -69,7 +74,7 @@ func TestTemplateResolverForCustomUrl(t *testing.T) {
6974 ConfigFile : "/config/file" ,
7075 }
7176
72- tmpl , err := r .Resolve (context . Background ( ))
77+ tmpl , err := r .Resolve (testContext ( t ))
7378 require .NoError (t , err )
7479
7580 assert .Equal (t , Custom , tmpl .name )
@@ -89,7 +94,7 @@ func TestTemplateResolverForCustomPath(t *testing.T) {
8994 ConfigFile : "/config/file" ,
9095 }
9196
92- tmpl , err := r .Resolve (context . Background ( ))
97+ tmpl , err := r .Resolve (testContext ( t ))
9398 require .NoError (t , err )
9499
95100 assert .Equal (t , Custom , tmpl .name )
0 commit comments