MCPcopy
hub / github.com/helm/helm / TestReadFile

Function TestReadFile

pkg/cli/values/options_test.go:54–248  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

52}
53
54func TestReadFile(t *testing.T) {
55 tests := []struct {
56 name string
57 filePath string
58 providers getter.Providers
59 setupFunc func(*testing.T) (string, func()) // setup temp files, return cleanup
60 expectError bool
61 expectStdin bool
62 expectedData []byte
63 }{
64 {
65 name: "stdin input with dash",
66 filePath: "-",
67 providers: getter.Providers{},
68 expectStdin: true,
69 expectError: false,
70 },
71 {
72 name: "stdin input with whitespace",
73 filePath: " - ",
74 providers: getter.Providers{},
75 expectStdin: true,
76 expectError: false,
77 },
78 {
79 name: "invalid URL parsing",
80 filePath: "://invalid-url",
81 providers: getter.Providers{},
82 expectError: true,
83 },
84 {
85 name: "local file - existing",
86 filePath: "test.txt",
87 providers: getter.Providers{},
88 setupFunc: func(t *testing.T) (string, func()) {
89 t.Helper()
90 tmpDir := t.TempDir()
91 filePath := filepath.Join(tmpDir, "test.txt")
92 content := []byte("local file content")
93 err := os.WriteFile(filePath, content, 0644)
94 if err != nil {
95 t.Fatal(err)
96 }
97 return filePath, func() {} // cleanup handled by t.TempDir()
98 },
99 expectError: false,
100 expectedData: []byte("local file content"),
101 },
102 {
103 name: "local file - non-existent",
104 filePath: "/non/existent/file.txt",
105 providers: getter.Providers{},
106 expectError: true,
107 },
108 {
109 name: "remote file with http scheme - success",
110 filePath: "http://example.com/values.yaml",
111 providers: getter.Providers{

Callers

nothing calls this directly

Calls 8

mockProviderFunction · 0.85
readFileFunction · 0.85
HelperMethod · 0.80
FatalMethod · 0.80
CloseMethod · 0.80
RunMethod · 0.65
WriteFileMethod · 0.45
WriteMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…