MCPcopy
hub / github.com/kubernetes/test-infra / TestHttpFileScheme

Function TestHttpFileScheme

kubetest/util_test.go:27–50  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

25)
26
27func TestHttpFileScheme(t *testing.T) {
28 expected := "some testdata"
29 tmpfile, err := os.CreateTemp("", "test_http_file_scheme")
30 if err != nil {
31 t.Errorf("Error creating temporary file: %v", err)
32 }
33 defer os.Remove(tmpfile.Name())
34 if _, err := tmpfile.WriteString(expected); err != nil {
35 t.Errorf("Error writing to temporary file: %v", err)
36 }
37 if err := tmpfile.Close(); err != nil {
38 t.Errorf("Error closing temporary file: %v", err)
39 }
40
41 fileURL := fmt.Sprintf("file://%s", tmpfile.Name())
42 buf := new(bytes.Buffer)
43 if err := httpRead(fileURL, buf); err != nil {
44 t.Errorf("Error reading temporary file through httpRead: %v", err)
45 }
46
47 if buf.String() != expected {
48 t.Errorf("httpRead(%s): expected %v, got %v", fileURL, expected, buf)
49 }
50}
51
52func TestGetLatestClusterUpTime(t *testing.T) {
53 const magicTime = "2011-11-11T11:11:11.111-11:00"

Callers

nothing calls this directly

Calls 3

httpReadFunction · 0.85
CloseMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected