Skip to content

Commit aa9cddf

Browse files
committed
fix: test
1 parent 4e19dda commit aa9cddf

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
package emailpassword
2+
3+
import (
4+
"io/ioutil"
5+
"net/http"
6+
"net/http/httptest"
7+
"testing"
8+
9+
"github.com/stretchr/testify/assert"
10+
"github.com/supertokens/supertokens-golang/supertokens"
11+
)
12+
13+
func TestAPIWithSupertokensMiddlewareButNotInitialized(t *testing.T) {
14+
BeforeEach()
15+
defer AfterEach()
16+
17+
mux := http.NewServeMux()
18+
testServer := httptest.NewServer(supertokens.Middleware(mux))
19+
defer testServer.Close()
20+
21+
resp, err := http.Post(testServer.URL+"/auth/signup", "application/json", nil)
22+
if err != nil {
23+
t.Error(err.Error())
24+
}
25+
26+
assert.Equal(t, 500, resp.StatusCode)
27+
defer resp.Body.Close()
28+
bodyBytes, err := ioutil.ReadAll(resp.Body)
29+
assert.NoError(t, err)
30+
31+
bodyStr := string(bodyBytes)
32+
assert.Equal(t, "initialisation not done. Did you forget to call the SuperTokens.init function?\n", bodyStr)
33+
}

0 commit comments

Comments
 (0)