| 1 | |
| 2 | |
| 3 | |
| 4 | package store |
| 5 | |
| 6 | import ( |
| 7 | "os" |
| 8 | "path/filepath" |
| 9 | "testing" |
| 10 | |
| 11 | "gotest.tools/v3/assert" |
| 12 | |
| 13 | "github.com/lima-vm/lima/v2/pkg/limatype/filenames" |
| 14 | ) |
| 15 | |
| 16 | func FuzzLoadYAMLByFilePath(f *testing.F) { |
| 17 | f.Fuzz(func(t *testing.T, fileContents []byte) { |
| 18 | localFile := filepath.Join(t.TempDir(), "yaml_file.yml") |
| 19 | err := os.WriteFile(localFile, fileContents, 0o600) |
| 20 | assert.NilError(t, err) |
| 21 | _, _ = LoadYAMLByFilePath(t.Context(), localFile) |
| 22 | }) |
| 23 | } |
| 24 | |
| 25 | func FuzzInspect(f *testing.F) { |
| 26 | f.Fuzz(func(t *testing.T, yml, limaVersion []byte) { |
| 27 | limaDir := t.TempDir() |
| 28 | t.Setenv("LIMA_HOME", limaDir) |
| 29 | err := os.MkdirAll(filepath.Join(limaDir, "fuzz-instance"), 0o700) |
| 30 | assert.NilError(t, err) |
| 31 | ymlFile := filepath.Join(limaDir, "fuzz-instance", filenames.LimaYAML) |
| 32 | limaVersionFile := filepath.Join(limaDir, filenames.LimaVersion) |
| 33 | err = os.WriteFile(ymlFile, yml, 0o600) |
| 34 | assert.NilError(t, err) |
| 35 | err = os.WriteFile(limaVersionFile, limaVersion, 0o600) |
| 36 | assert.NilError(t, err) |
| 37 | _, _ = Inspect(t.Context(), "fuzz-instance") |
| 38 | }) |
| 39 | } |