diff --git a/Dockerfile b/Dockerfile index 91213152..4bd0886e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,7 +4,7 @@ WORKDIR /src RUN apk add make git RUN make -FROM debian:stable-20230612 +FROM debian:stable-20230703 RUN apt-get update --yes && \ apt-get install --no-install-recommends --yes git ca-certificates && \ rm -rf /var/lib/apt/lists/* diff --git a/internal/checks/base.go b/internal/checks/base.go index 4d7c183e..d51f49d2 100644 --- a/internal/checks/base.go +++ b/internal/checks/base.go @@ -2,6 +2,7 @@ package checks import ( "context" + "encoding/json" "errors" "fmt" @@ -78,6 +79,10 @@ func ParseSeverity(s string) (Severity, error) { } } +func (s Severity) MarshalJSON() ([]byte, error) { + return json.Marshal(s.String()) +} + const ( // Information doesn't count as a problem, it's a comment Information Severity = iota diff --git a/internal/reporter/json_test.go b/internal/reporter/json_test.go index 59040436..7a30b33d 100644 --- a/internal/reporter/json_test.go +++ b/internal/reporter/json_test.go @@ -44,6 +44,6 @@ func TestJSONReporter(t *testing.T) { defer jsonFile.Close() byteValue, err := io.ReadAll(jsonFile) require.NoError(t, err, "Error reading json") - expected := "[{\"reportedPath\":\"\",\"sourcePath\":\"foo.txt\",\"rule\":{\"name\":\"sum errors\",\"type\":\"recording\"},\"problem\":{\"Fragment\":\"syntax error\",\"Lines\":[2],\"Reporter\":\"mock\",\"Text\":\"syntax error\",\"Severity\":3},\"owner\":\"\"}]" + expected := "[{\"reportedPath\":\"\",\"sourcePath\":\"foo.txt\",\"rule\":{\"name\":\"sum errors\",\"type\":\"recording\"},\"problem\":{\"Fragment\":\"syntax error\",\"Lines\":[2],\"Reporter\":\"mock\",\"Text\":\"syntax error\",\"Severity\":\"Fatal\"},\"owner\":\"\"}]" require.Equal(t, expected, string(byteValue)) }