@@ -26,11 +26,12 @@ import (
2626 "testing"
2727 "time"
2828
29- "github.com/compose-spec/compose-go/types"
3029 "github.com/google/go-cmp/cmp/cmpopts"
3130 "github.com/sirupsen/logrus"
3231 "gotest.tools/v3/assert"
3332 is "gotest.tools/v3/assert/cmp"
33+
34+ "github.com/compose-spec/compose-go/types"
3435)
3536
3637func buildConfigDetails (yaml string , env map [string ]string ) types.ConfigDetails {
@@ -1853,16 +1854,29 @@ func TestLoadWithExtends(t *testing.T) {
18531854 actual , err := Load (configDetails )
18541855 assert .NilError (t , err )
18551856
1857+ extendsDir , err := filepath .Abs (filepath .Join ("testdata" , "subdir" ))
1858+ assert .NilError (t , err )
1859+
1860+ expectedEnvFilePath := filepath .Join (extendsDir , "extra.env" )
1861+
1862+ expectedExtendsPath := filepath .Join (
1863+ extendsDir ,
1864+ "compose-test-extends-imported.yaml" ,
1865+ )
1866+
18561867 expServices := types.Services {
18571868 {
18581869 Name : "importer" ,
18591870 Image : "nginx" ,
18601871 Extends : types.ExtendsConfig {
1861- "file" : strPtr ( "compose-test-extends-imported.yaml" ) ,
1872+ "file" : & expectedExtendsPath ,
18621873 "service" : strPtr ("imported" ),
18631874 },
1864- Environment : types.MappingWithEquals {},
1865- Networks : map [string ]* types.ServiceNetworkConfig {"default" : nil },
1875+ Environment : types.MappingWithEquals {
1876+ "SOURCE" : strPtr ("extends" ),
1877+ },
1878+ EnvFile : []string {expectedEnvFilePath },
1879+ Networks : map [string ]* types.ServiceNetworkConfig {"default" : nil },
18661880 Volumes : []types.ServiceVolumeConfig {{
18671881 Type : "bind" ,
18681882 Source : "/opt/data" ,
@@ -1889,6 +1903,13 @@ func TestLoadWithExtendsWithContextUrl(t *testing.T) {
18891903 actual , err := Load (configDetails )
18901904 assert .NilError (t , err )
18911905
1906+ expectedExtendsPath , err := filepath .Abs (
1907+ filepath .Join (
1908+ "testdata" ,
1909+ "compose-test-extends-with-context-url-imported.yaml" ,
1910+ ),
1911+ )
1912+ assert .NilError (t , err )
18921913 expServices := types.Services {
18931914 {
18941915 Name : "importer-with-https-url" ,
@@ -1897,7 +1918,7 @@ func TestLoadWithExtendsWithContextUrl(t *testing.T) {
18971918 Dockerfile : "Dockerfile" ,
18981919 },
18991920 Extends : types.ExtendsConfig {
1900- "file" : strPtr ( "compose-test-extends-with-context-url-imported.yaml" ) ,
1921+ "file" : & expectedExtendsPath ,
19011922 "service" : strPtr ("imported-with-https-url" ),
19021923 },
19031924 Environment : types.MappingWithEquals {},
0 commit comments