cli: remove code duplication in test

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
This commit is contained in:
Anna Shaleva 2023-05-19 13:22:20 +03:00
parent 2f4fb3a079
commit ddfbf7a434

View file

@ -474,15 +474,8 @@ func TestLoad(t *testing.T) {
tmpDir := t.TempDir()
checkLoadgo := func(t *testing.T, cName, cErrName string) {
filename := filepath.Join(tmpDir, cName)
require.NoError(t, os.WriteFile(filename, []byte(src), os.ModePerm))
filename = "'" + filename + "'"
filename := prepareLoadgoSrc(t, tmpDir, src)
filenameErr := filepath.Join(tmpDir, cErrName)
require.NoError(t, os.WriteFile(filenameErr, []byte(src+"invalid_token"), os.ModePerm))
filenameErr = "'" + filenameErr + "'"
goMod := []byte(`module test.example/vmcli
go 1.18`)
require.NoError(t, os.WriteFile(filepath.Join(tmpDir, "go.mod"), goMod, os.ModePerm))
e := newTestVMCLI(t)
e.runProgWithTimeout(t, 10*time.Second,