@@ -26,11 +26,12 @@ import (
26
26
"testing"
27
27
"time"
28
28
29
- "github.com/compose-spec/compose-go/types"
30
29
"github.com/google/go-cmp/cmp/cmpopts"
31
30
"github.com/sirupsen/logrus"
32
31
"gotest.tools/v3/assert"
33
32
is "gotest.tools/v3/assert/cmp"
33
+
34
+ "github.com/compose-spec/compose-go/types"
34
35
)
35
36
36
37
func buildConfigDetails (yaml string , env map [string ]string ) types.ConfigDetails {
@@ -1853,16 +1854,29 @@ func TestLoadWithExtends(t *testing.T) {
1853
1854
actual , err := Load (configDetails )
1854
1855
assert .NilError (t , err )
1855
1856
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
+
1856
1867
expServices := types.Services {
1857
1868
{
1858
1869
Name : "importer" ,
1859
1870
Image : "nginx" ,
1860
1871
Extends : types.ExtendsConfig {
1861
- "file" : strPtr ( "compose-test-extends-imported.yaml" ) ,
1872
+ "file" : & expectedExtendsPath ,
1862
1873
"service" : strPtr ("imported" ),
1863
1874
},
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 },
1866
1880
Volumes : []types.ServiceVolumeConfig {{
1867
1881
Type : "bind" ,
1868
1882
Source : "/opt/data" ,
@@ -1889,6 +1903,13 @@ func TestLoadWithExtendsWithContextUrl(t *testing.T) {
1889
1903
actual , err := Load (configDetails )
1890
1904
assert .NilError (t , err )
1891
1905
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 )
1892
1913
expServices := types.Services {
1893
1914
{
1894
1915
Name : "importer-with-https-url" ,
@@ -1897,7 +1918,7 @@ func TestLoadWithExtendsWithContextUrl(t *testing.T) {
1897
1918
Dockerfile : "Dockerfile" ,
1898
1919
},
1899
1920
Extends : types.ExtendsConfig {
1900
- "file" : strPtr ( "compose-test-extends-with-context-url-imported.yaml" ) ,
1921
+ "file" : & expectedExtendsPath ,
1901
1922
"service" : strPtr ("imported-with-https-url" ),
1902
1923
},
1903
1924
Environment : types.MappingWithEquals {},
0 commit comments