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

Function TestHandleErrorResponse

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

Source from the content-addressed store, hash-verified

614}
615
616func TestHandleErrorResponse(t *testing.T) {
617 handler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
618 w.WriteHeader(404)
619 })
620
621 ts := httptest.NewServer(handler)
622 defer ts.Close()
623
624 tmpDir, err := os.MkdirTemp("", "submit-nonsuccess")
625 defer os.RemoveAll(tmpDir)
626 assert.NoError(t, err)
627
628 v := viper.New()
629 v.Set("token", "abc123")
630 v.Set("workspace", tmpDir)
631 v.Set("apibaseurl", ts.URL)
632
633 cfg := config.Config{
634 Persister: config.InMemoryPersister{},
635 UserViperConfig: v,
636 DefaultBaseURL: "http://example.com",
637 }
638
639 dir := filepath.Join(tmpDir, "bogus-track", "bogus-exercise")
640 os.MkdirAll(filepath.Join(dir, "subdir"), os.FileMode(0755))
641 writeFakeMetadata(t, dir, "bogus-track", "bogus-exercise")
642
643 err = os.WriteFile(filepath.Join(dir, "file-1.txt"), []byte("This is file 1"), os.FileMode(0755))
644 assert.NoError(t, err)
645
646 files := []string{
647 filepath.Join(dir, "file-1.txt"),
648 }
649
650 err = runSubmit(cfg, pflag.NewFlagSet("fake", pflag.PanicOnError), files)
651 assert.Error(t, err)
652}
653
654func TestSubmissionNotConnectedToRequesterAccount(t *testing.T) {
655 submittedFiles := map[string]string{}

Callers

nothing calls this directly

Calls 3

writeFakeMetadataFunction · 0.85
runSubmitFunction · 0.85
ErrorMethod · 0.45

Tested by

no test coverage detected