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

Function TestSubmitOnlyEmptyFile

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

Source from the content-addressed store, hash-verified

426}
427
428func TestSubmitOnlyEmptyFile(t *testing.T) {
429 co := newCapturedOutput()
430 co.override()
431 defer co.reset()
432
433 tmpDir, err := os.MkdirTemp("", "just-an-empty-file")
434 defer os.RemoveAll(tmpDir)
435 assert.NoError(t, err)
436
437 dir := filepath.Join(tmpDir, "bogus-track", "bogus-exercise")
438 os.MkdirAll(dir, os.FileMode(0755))
439
440 writeFakeMetadata(t, dir, "bogus-track", "bogus-exercise")
441
442 v := viper.New()
443 v.Set("token", "abc123")
444 v.Set("workspace", tmpDir)
445 v.Set("apibaseurl", "http://api.example.com")
446
447 cfg := config.Config{
448 Persister: config.InMemoryPersister{},
449 UserViperConfig: v,
450 }
451
452 file := filepath.Join(dir, "file.txt")
453 err = os.WriteFile(file, []byte(""), os.FileMode(0755))
454
455 err = runSubmit(cfg, pflag.NewFlagSet("fake", pflag.PanicOnError), []string{file})
456 if assert.Error(t, err) {
457 assert.Regexp(t, "No files found", err.Error())
458 }
459}
460
461func TestSubmitFilesFromDifferentSolutions(t *testing.T) {
462 tmpDir, err := os.MkdirTemp("", "dir-1-submit")

Callers

nothing calls this directly

Calls 6

newCapturedOutputFunction · 0.85
writeFakeMetadataFunction · 0.85
runSubmitFunction · 0.85
overrideMethod · 0.80
resetMethod · 0.80
ErrorMethod · 0.45

Tested by

no test coverage detected