@@ -42,15 +42,15 @@ type testSpin struct {
4242 cmd * exec.Cmd
4343}
4444
45- func startSpin (t * testing.T , dir string ) * testSpin {
45+ func startSpin (t * testing.T , dir string , extraArgs ... string ) * testSpin {
4646 buildApp (t , dir )
4747
4848 url := getFreePort (t )
4949
5050 // long timeout because... ci
5151 ctx , cancel := context .WithTimeout (context .Background (), 10 * time .Minute )
5252
53- cmd := exec .CommandContext (ctx , spinBinary , "up" , "--listen" , url )
53+ cmd := exec .CommandContext (ctx , spinBinary , append ([] string { "up" , "--listen" , url }, extraArgs ... ) ... )
5454 cmd .Dir = dir
5555 stderr := new (bytes.Buffer )
5656 cmd .Stderr = stderr
@@ -144,6 +144,30 @@ func TestKeyValue(t *testing.T) {
144144 }
145145}
146146
147+ func TestVariables (t * testing.T ) {
148+ spin := startSpin (t , "variables/testdata/variables" )
149+ defer spin .cancel ()
150+
151+ resp := retryGet (t , spin .url )
152+ spin .cancel ()
153+ if resp .Body == nil {
154+ t .Fatal ("body is nil" )
155+ }
156+ t .Log (resp .Status )
157+ b , err := io .ReadAll (resp .Body )
158+ resp .Body .Close ()
159+ if err != nil {
160+ t .Fatal (err )
161+ }
162+
163+ // assert response body
164+ want := "message: I'm a teapot\n "
165+ got := string (b )
166+ if want != got {
167+ t .Fatalf ("body is not equal: want = %q got = %q" , want , got )
168+ }
169+ }
170+
147171// TestBuildExamples ensures that the tinygo examples will build successfully.
148172func TestBuildExamples (t * testing.T ) {
149173 examples , err := os .ReadDir ("examples" )
0 commit comments