diff options
Diffstat (limited to 'cmd')
-rw-r--r-- | cmd/tfstated/get.go | 9 | ||||
-rw-r--r-- | cmd/tfstated/get_test.go | 2 |
2 files changed, 2 insertions, 9 deletions
diff --git a/cmd/tfstated/get.go b/cmd/tfstated/get.go index 7d54970..6bc4466 100644 --- a/cmd/tfstated/get.go +++ b/cmd/tfstated/get.go @@ -1,8 +1,6 @@ package main import ( - "database/sql" - "errors" "fmt" "net/http" @@ -20,12 +18,7 @@ func handleGet(db *database.DB) http.Handler { } if data, err := db.GetState(r.URL.Path); err != nil { - if errors.Is(err, sql.ErrNoRows) { - _ = errorResponse(w, http.StatusNotFound, - fmt.Errorf("state path not found: %s", r.URL.Path)) - } else { - _ = errorResponse(w, http.StatusInternalServerError, err) - } + _ = errorResponse(w, http.StatusInternalServerError, err) } else { w.WriteHeader(http.StatusOK) _, _ = w.Write(data) diff --git a/cmd/tfstated/get_test.go b/cmd/tfstated/get_test.go index a6d9382..aa56026 100644 --- a/cmd/tfstated/get_test.go +++ b/cmd/tfstated/get_test.go @@ -18,7 +18,7 @@ func TestGet(t *testing.T) { msg string }{ {"GET", &url.URL{Path: "/"}, nil, "", http.StatusBadRequest, "/"}, - {"GET", &url.URL{Path: "/non_existent_get"}, nil, "", http.StatusNotFound, "non existent"}, + {"GET", &url.URL{Path: "/non_existent_get"}, strings.NewReader(""), "", http.StatusOK, "non existent"}, {"POST", &url.URL{Path: "/test_get"}, strings.NewReader("the_test_get"), "", http.StatusOK, "/test_get"}, {"GET", &url.URL{Path: "/test_get"}, nil, "the_test_get", http.StatusOK, "/test_get"}, } |