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