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() tmpDir := t.TempDir()
checkLoadgo := func(t *testing.T, cName, cErrName string) { checkLoadgo := func(t *testing.T, cName, cErrName string) {
filename := filepath.Join(tmpDir, cName) filename := prepareLoadgoSrc(t, tmpDir, src)
require.NoError(t, os.WriteFile(filename, []byte(src), os.ModePerm))
filename = "'" + filename + "'"
filenameErr := filepath.Join(tmpDir, cErrName) 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 := newTestVMCLI(t)
e.runProgWithTimeout(t, 10*time.Second, e.runProgWithTimeout(t, 10*time.Second,