MCPcopy Create free account
hub / github.com/exercism/cli / TestSubmitNonExistentFile

Function TestSubmitNonExistentFile

cmd/submit_test.go:51–81  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

49}
50
51func TestSubmitNonExistentFile(t *testing.T) {
52 tmpDir, err := os.MkdirTemp("", "submit-no-such-file")
53 defer os.RemoveAll(tmpDir)
54 assert.NoError(t, err)
55
56 v := viper.New()
57 v.Set("token", "abc123")
58 v.Set("workspace", tmpDir)
59 v.Set("apibaseurl", "http://api.example.com")
60
61 cfg := config.Config{
62 Persister: config.InMemoryPersister{},
63 UserViperConfig: v,
64 DefaultBaseURL: "http://example.com",
65 }
66
67 err = os.WriteFile(filepath.Join(tmpDir, "file-1.txt"), []byte("This is file 1"), os.FileMode(0755))
68 assert.NoError(t, err)
69
70 err = os.WriteFile(filepath.Join(tmpDir, "file-2.txt"), []byte("This is file 2"), os.FileMode(0755))
71 assert.NoError(t, err)
72 files := []string{
73 filepath.Join(tmpDir, "file-1.txt"),
74 "no-such-file.txt",
75 filepath.Join(tmpDir, "file-2.txt"),
76 }
77 err = runSubmit(cfg, pflag.NewFlagSet("fake", pflag.PanicOnError), files)
78 if assert.Error(t, err) {
79 assert.Regexp(t, "cannot be found", err.Error())
80 }
81}
82
83func TestSubmitExerciseWithoutMetadataFile(t *testing.T) {
84 tmpDir, err := os.MkdirTemp("", "no-metadata-file")

Callers

nothing calls this directly

Calls 2

runSubmitFunction · 0.85
ErrorMethod · 0.45

Tested by

no test coverage detected