@@ -4,6 +4,9 @@ package integration_test
44
55import  (
66	"context" 
7+ 	"io/ioutil" 
8+ 	"os" 
9+ 	"path/filepath" 
710	"testing" 
811
912	"github.com/stretchr/testify/require" 
@@ -14,7 +17,7 @@ func TestServeLaunchpadAppWithWasm(t *testing.T) {
1417	var  (
1518		env      =  newEnv (t )
1619		apath    =  env .Scaffold ("blog" , Launchpad )
17- 		servers  =  env .RandomizeServerPorts (apath )
20+ 		servers  =  env .RandomizeServerPorts (apath ,  "" )
1821	)
1922
2023	env .Must (env .Exec ("add Wasm module" ,
@@ -32,7 +35,7 @@ func TestServeLaunchpadAppWithWasm(t *testing.T) {
3235		defer  cancel ()
3336		isBackendAliveErr  =  env .IsAppServed (ctx , servers )
3437	}()
35- 	env .Must (env .Serve ("should serve with Wasm" , apath , "" , "" , ExecCtx (ctx )))
38+ 	env .Must (env .Serve ("should serve with Wasm" , apath , "" , "" , "" ,  ExecCtx (ctx )))
3639
3740	require .NoError (t , isBackendAliveErr , "app cannot get online in time" )
3841}
@@ -41,7 +44,7 @@ func TestServeLaunchpadAppWithCustomHomes(t *testing.T) {
4144	var  (
4245		env      =  newEnv (t )
4346		apath    =  env .Scaffold ("blog2" , Launchpad )
44- 		servers  =  env .RandomizeServerPorts (apath )
47+ 		servers  =  env .RandomizeServerPorts (apath ,  "" )
4548	)
4649
4750	var  (
@@ -52,7 +55,7 @@ func TestServeLaunchpadAppWithCustomHomes(t *testing.T) {
5255		defer  cancel ()
5356		isBackendAliveErr  =  env .IsAppServed (ctx , servers )
5457	}()
55- 	env .Must (env .Serve ("should serve with Wasm" , apath , "./home" , "./clihome" , ExecCtx (ctx )))
58+ 	env .Must (env .Serve ("should serve with Wasm" , apath , "./home" , "./clihome" , "" ,  ExecCtx (ctx )))
5659
5760	require .NoError (t , isBackendAliveErr , "app cannot get online in time" )
5861}
@@ -61,11 +64,11 @@ func TestServeLaunchpadAppWithConfigHomes(t *testing.T) {
6164	var  (
6265		env      =  newEnv (t )
6366		apath    =  env .Scaffold ("blog3" , Launchpad )
64- 		servers  =  env .RandomizeServerPorts (apath )
67+ 		servers  =  env .RandomizeServerPorts (apath ,  "" )
6568	)
6669
6770	// Set config homes 
68- 	env .SetRandomHomeConfig (apath )
71+ 	env .SetRandomHomeConfig (apath ,  "" )
6972
7073	var  (
7174		ctx , cancel        =  context .WithTimeout (env .Ctx (), serveTimeout )
@@ -75,7 +78,7 @@ func TestServeLaunchpadAppWithConfigHomes(t *testing.T) {
7578		defer  cancel ()
7679		isBackendAliveErr  =  env .IsAppServed (ctx , servers )
7780	}()
78- 	env .Must (env .Serve ("should serve with Wasm" , apath , "" , "" , ExecCtx (ctx )))
81+ 	env .Must (env .Serve ("should serve with Wasm" , apath , "" , "" , "" ,  ExecCtx (ctx )))
7982
8083	require .NoError (t , isBackendAliveErr , "app cannot get online in time" )
8184}
@@ -84,7 +87,7 @@ func TestServeStargateWithWasm(t *testing.T) {
8487	var  (
8588		env      =  newEnv (t )
8689		apath    =  env .Scaffold ("sgblog" , Stargate )
87- 		servers  =  env .RandomizeServerPorts (apath )
90+ 		servers  =  env .RandomizeServerPorts (apath ,  "" )
8891	)
8992
9093	env .Must (env .Exec ("add Wasm module" ,
@@ -102,7 +105,7 @@ func TestServeStargateWithWasm(t *testing.T) {
102105		defer  cancel ()
103106		isBackendAliveErr  =  env .IsAppServed (ctx , servers )
104107	}()
105- 	env .Must (env .Serve ("should serve with Stargate version" , apath , "" , "" , ExecCtx (ctx )))
108+ 	env .Must (env .Serve ("should serve with Stargate version" , apath , "" , "" , "" ,  ExecCtx (ctx )))
106109
107110	require .NoError (t , isBackendAliveErr , "app cannot get online in time" )
108111}
@@ -111,7 +114,7 @@ func TestServeStargateWithCustomHome(t *testing.T) {
111114	var  (
112115		env      =  newEnv (t )
113116		apath    =  env .Scaffold ("sgblog2" , Stargate )
114- 		servers  =  env .RandomizeServerPorts (apath )
117+ 		servers  =  env .RandomizeServerPorts (apath ,  "" )
115118	)
116119
117120	var  (
@@ -122,7 +125,7 @@ func TestServeStargateWithCustomHome(t *testing.T) {
122125		defer  cancel ()
123126		isBackendAliveErr  =  env .IsAppServed (ctx , servers )
124127	}()
125- 	env .Must (env .Serve ("should serve with Stargate version" , apath , "./home" , "" , ExecCtx (ctx )))
128+ 	env .Must (env .Serve ("should serve with Stargate version" , apath , "./home" , "" , "" ,  ExecCtx (ctx )))
126129
127130	require .NoError (t , isBackendAliveErr , "app cannot get online in time" )
128131}
@@ -131,11 +134,11 @@ func TestServeStargateWithConfigHome(t *testing.T) {
131134	var  (
132135		env      =  newEnv (t )
133136		apath    =  env .Scaffold ("sgblog3" , Stargate )
134- 		servers  =  env .RandomizeServerPorts (apath )
137+ 		servers  =  env .RandomizeServerPorts (apath ,  "" )
135138	)
136139
137140	// Set config homes 
138- 	env .SetRandomHomeConfig (apath )
141+ 	env .SetRandomHomeConfig (apath ,  "" )
139142
140143	var  (
141144		ctx , cancel        =  context .WithTimeout (env .Ctx (), serveTimeout )
@@ -145,7 +148,40 @@ func TestServeStargateWithConfigHome(t *testing.T) {
145148		defer  cancel ()
146149		isBackendAliveErr  =  env .IsAppServed (ctx , servers )
147150	}()
148- 	env .Must (env .Serve ("should serve with Stargate version" , apath , "" , "" , ExecCtx (ctx )))
151+ 	env .Must (env .Serve ("should serve with Stargate version" , apath , "" , "" , "" , ExecCtx (ctx )))
152+ 
153+ 	require .NoError (t , isBackendAliveErr , "app cannot get online in time" )
154+ }
155+ 
156+ func  TestServeStargateWithCustomConfigFile (t  * testing.T ) {
157+ 	tmpDir , err  :=  ioutil .TempDir ("" , "starporttest" )
158+ 	require .NoError (t , err )
159+ 	defer  os .RemoveAll (tmpDir )
160+ 
161+ 	var  (
162+ 		env    =  newEnv (t )
163+ 		apath  =  env .Scaffold ("sgblog4" , Stargate )
164+ 	)
165+ 	// Move config 
166+ 	newConfig  :=  "new_config.yml" 
167+ 	newConfigPath  :=  filepath .Join (tmpDir , newConfig )
168+ 	err  =  os .Rename (filepath .Join (apath , "config.yml" ), newConfigPath )
169+ 	require .NoError (t , err )
170+ 
171+ 	servers  :=  env .RandomizeServerPorts (tmpDir , newConfig )
172+ 
173+ 	// Set config homes 
174+ 	env .SetRandomHomeConfig (tmpDir , newConfig )
175+ 
176+ 	var  (
177+ 		ctx , cancel        =  context .WithTimeout (env .Ctx (), serveTimeout )
178+ 		isBackendAliveErr  error 
179+ 	)
180+ 	go  func () {
181+ 		defer  cancel ()
182+ 		isBackendAliveErr  =  env .IsAppServed (ctx , servers )
183+ 	}()
184+ 	env .Must (env .Serve ("should serve with Stargate version" , apath , "" , "" , newConfigPath , ExecCtx (ctx )))
149185
150186	require .NoError (t , isBackendAliveErr , "app cannot get online in time" )
151187}
0 commit comments