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

Function TestSubmitExerciseWithoutMetadataFile

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

Source from the content-addressed store, hash-verified

81}
82
83func TestSubmitExerciseWithoutMetadataFile(t *testing.T) {
84 tmpDir, err := os.MkdirTemp("", "no-metadata-file")
85 defer os.RemoveAll(tmpDir)
86 assert.NoError(t, err)
87
88 dir := filepath.Join(tmpDir, "bogus-track", "bogus-exercise")
89 os.MkdirAll(dir, os.FileMode(0755))
90
91 file := filepath.Join(dir, "file.txt")
92 err = os.WriteFile(file, []byte("This is a file."), os.FileMode(0755))
93 assert.NoError(t, err)
94
95 v := viper.New()
96 v.Set("token", "abc123")
97 v.Set("workspace", tmpDir)
98 v.Set("apibaseurl", "http://api.example.com")
99
100 cfg := config.Config{
101 Persister: config.InMemoryPersister{},
102 Dir: tmpDir,
103 UserViperConfig: v,
104 }
105
106 err = runSubmit(cfg, pflag.NewFlagSet("fake", pflag.PanicOnError), []string{file})
107 if assert.Error(t, err) {
108 assert.Regexp(t, "doesn't have the necessary metadata", err.Error())
109 }
110}
111
112func TestGetExerciseSolutionFiles(t *testing.T) {
113

Callers

nothing calls this directly

Calls 2

runSubmitFunction · 0.85
ErrorMethod · 0.45

Tested by

no test coverage detected