mirror of
https://github.com/taigrr/wasm-experiments
synced 2025-01-18 04:03:21 -08:00
Add experimental browser test
This commit is contained in:
30
test/wasm_test.go
Normal file
30
test/wasm_test.go
Normal file
@@ -0,0 +1,30 @@
|
||||
//+build js,wasm
|
||||
|
||||
package wasm_test
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestFetch(t *testing.T) {
|
||||
resp, err := http.Get("http://example.com/")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
|
||||
if resp.StatusCode != http.StatusOK {
|
||||
t.Errorf("Unexpected StatusCode %d", resp.StatusCode)
|
||||
}
|
||||
|
||||
rb, err := ioutil.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
if string(rb) != "stuff" {
|
||||
t.Errorf("Unexpected Body: %q", string(rb))
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user