MCPcopy
hub / github.com/spf13/viper / initDirs

Function initDirs

viper_test.go:126–151  ·  view source on GitHub ↗

initDirs makes directories for testing.

(t *testing.T)

Source from the content-addressed store, hash-verified

124
125// initDirs makes directories for testing.
126func initDirs(t *testing.T) (string, string) {
127 var (
128 testDirs = []string{`a a`, `b`, `C_`}
129 config = `improbable`
130 )
131
132 if runtime.GOOS != "windows" {
133 testDirs = append(testDirs, `d\d`)
134 }
135
136 root := t.TempDir()
137
138 for _, dir := range testDirs {
139 innerDir := filepath.Join(root, dir)
140 err := os.Mkdir(innerDir, 0o750)
141 require.NoError(t, err)
142
143 err = os.WriteFile(
144 filepath.Join(innerDir, config+".toml"),
145 []byte(`key = "value is `+dir+`"`+"\n"),
146 0o640)
147 require.NoError(t, err)
148 }
149
150 return root, config
151}
152
153// stubs for PFlag Values.
154type stringValue string

Callers 3

TestDirsSearchFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected