MCPcopy Index your code
hub / github.com/coder/coder / CreateTemplateVersionSource

Function CreateTemplateVersionSource

cli/clitest/clitest.go:120–132  ·  view source on GitHub ↗

CreateTemplateVersionSource writes the echo provisioner responses into a new temporary testing directory.

(t *testing.T, responses *echo.Responses)

Source from the content-addressed store, hash-verified

118// CreateTemplateVersionSource writes the echo provisioner responses into a
119// new temporary testing directory.
120func CreateTemplateVersionSource(t *testing.T, responses *echo.Responses) string {
121 directory := t.TempDir()
122 f, err := os.CreateTemp(directory, "*.tf")
123 require.NoError(t, err)
124 _ = f.Close()
125 f, err = os.Create(filepath.Join(directory, ".terraform.lock.hcl"))
126 require.NoError(t, err)
127 _ = f.Close()
128 data, err := echo.Tar(responses)
129 require.NoError(t, err)
130 extractTar(t, data, directory)
131 return directory
132}
133
134func extractTar(t *testing.T, data []byte, directory string) {
135 reader := tar.NewReader(bytes.NewBuffer(data))

Callers 4

TestCliTemplateCreateFunction · 0.92
TestTemplatePushFunction · 0.92
TestCliFunction · 0.92
TestTemplateCreateFunction · 0.92

Calls 5

TarFunction · 0.92
extractTarFunction · 0.85
TempDirMethod · 0.65
CloseMethod · 0.65
CreateMethod · 0.65

Tested by 4

TestCliTemplateCreateFunction · 0.74
TestTemplatePushFunction · 0.74
TestCliFunction · 0.74
TestTemplateCreateFunction · 0.74