-
Notifications
You must be signed in to change notification settings - Fork 122
/
mock_util_test.go
35 lines (30 loc) · 707 Bytes
/
mock_util_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// Copyright (c) 2021-2022 Snowflake Computing Inc. All rights reserved.
package gosnowflake
import (
"io"
"net/http"
"strconv"
"testing"
)
/** This file contains helper functions for tests only. **/
func resetHTTPMocks(t *testing.T) {
_, err := http.Post("http://localhost:12345/reset", "text/plain", nil)
if err != nil {
t.Fatalf("Cannot reset HTTP mocks")
}
}
func getMocksInvocations(t *testing.T) int {
resp, err := http.Get("http://localhost:12345/invocations")
if err != nil {
t.Fatalf(err.Error())
}
bytes, err := io.ReadAll(resp.Body)
if err != nil {
t.Fatalf(err.Error())
}
ret, err := strconv.Atoi(string(bytes))
if err != nil {
t.Fatalf(err.Error())
}
return ret
}