File tree Expand file tree Collapse file tree 2 files changed +15
-3
lines changed
Expand file tree Collapse file tree 2 files changed +15
-3
lines changed Original file line number Diff line number Diff line change @@ -556,7 +556,7 @@ func TestClient_New_ImageRegistryDefaults(t *testing.T) {
556556// Deploy (and confirms expected fields calculated).
557557func TestClient_New_Delegation (t * testing.T ) {
558558 var (
559- root = "testdata/example.com/test-new-delegates" // .. in which to initialize
559+ root = absPath ( "testdata/example.com/test-new-delegates" ) // .. in which to initialize
560560 expectedName = "test-new-delegates" // expected to be derived
561561 expectedImage = "example.com/alice/test-new-delegates:latest"
562562 builder = mock .NewBuilder ()
@@ -642,7 +642,7 @@ func TestClient_New_Delegation(t *testing.T) {
642642// See TestClient_Runner for the test of the default runner implementation.
643643func TestClient_Run (t * testing.T ) {
644644 // Create the root function directory
645- root := "testdata/example.com/test-run"
645+ root := absPath ( "testdata/example.com/test-run" )
646646 defer Using (t , root )()
647647
648648 // client with the mock runner and the new test function
@@ -2235,3 +2235,11 @@ func TestClient_BuildPopulatesRuntimeImage(t *testing.T) {
22352235 t .Fatalf ("written image in ./.func/built-image '%s' does not match expected '%s'" , got , expect )
22362236 }
22372237}
2238+
2239+ func absPath (p string ) string {
2240+ abs , err := filepath .Abs (p )
2241+ if err != nil {
2242+ panic (err )
2243+ }
2244+ return abs
2245+ }
Original file line number Diff line number Diff line change @@ -56,7 +56,8 @@ type Function struct {
5656 // For details see the .Migrated() and .Migrate() methods.
5757 SpecVersion string `yaml:"specVersion"` // semver format
5858
59- // Root on disk at which to find/create source and config files.
59+ // Root is the absolute path on disk at which to find/create source and
60+ // config files.
6061 Root string `yaml:"-"`
6162
6263 // Name of the function.
@@ -271,6 +272,9 @@ func NewFunction(root string) (f Function, err error) {
271272 return
272273 }
273274 }
275+ if root , err = filepath .Abs (root ); err != nil {
276+ return
277+ }
274278 f .Root = root // path is not persisted, as this is the purview of the FS
275279
276280 // Path must exist and be a directory
You can’t perform that action at this time.
0 commit comments