Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions parser_extra_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"net/http"
"net/http/httptest"
"os"
"reflect"
"strings"
"testing"
)
Expand Down Expand Up @@ -262,3 +263,31 @@ localisation:
}

}

func TestParseStreamVersion06(t *testing.T) {
data, err := os.ReadFile("testdata/v0/valid/no-network/standard_minimal_example.yml")
if err != nil {
t.Fatal(err)
}

for _, version := range []string{"0.6", "0.6.0"} {
t.Run(version, func(t *testing.T) {
p, err := NewParser(ParserConfig{DisableNetwork: true})
if err != nil {
t.Fatal(err)
}

input := strings.Replace(string(data), `publiccodeYmlVersion: "0"`, `publiccodeYmlVersion: "`+version+`"`, 1)
pc, err := p.ParseStream(strings.NewReader(input))
if pc == nil {
t.Fatal("expected a parsed document")
}
expected := ValidationResults{
ValidationWarning{"", "publiccodeYmlVersion", "v" + version + " is not the latest version, use '0'. Parsing this file as v0.8.", 1, 1},
}
if !reflect.DeepEqual(err, expected) {
t.Fatalf("unexpected diagnostics: got %#v, want %#v", err, expected)
}
})
}
}
1 change: 1 addition & 0 deletions publiccode.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ var SupportedVersions = []string{
"0.3", "0.3.0",
"0.4", "0.4.0",
"0.5.0", "0.5",
"0.6.0", "0.6",
"0.7.0", "0.7",
"0.8.0", "0.8",
}
Expand Down
2 changes: 1 addition & 1 deletion v0.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (

// PublicCodeV0 defines how a publiccode.yml v0.x is structured.
type PublicCodeV0 struct {
PubliccodeYamlVersion string `json:"publiccodeYmlVersion" validate:"required,oneof=0 0.2 0.2.0 0.2.1 0.2.2 0.3 0.3.0 0.4 0.4.0 0.5 0.5.0 0.7 0.7.0 0.8 0.8.0" yaml:"publiccodeYmlVersion"`
PubliccodeYamlVersion string `json:"publiccodeYmlVersion" validate:"required,oneof=0 0.2 0.2.0 0.2.1 0.2.2 0.3 0.3.0 0.4 0.4.0 0.5 0.5.0 0.6 0.6.0 0.7 0.7.0 0.8 0.8.0" yaml:"publiccodeYmlVersion"`

Name string `json:"name" validate:"required" yaml:"name"`
ApplicationSuite string `json:"applicationSuite,omitempty" yaml:"applicationSuite,omitempty"`
Expand Down
2 changes: 1 addition & 1 deletion v0_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ func TestInvalidTestcasesV0(t *testing.T) {
ValidationError{
"",
"publiccodeYmlVersion",
"unsupported version: '1'. Supported versions: 0, 0.2, 0.2.0, 0.2.1, 0.2.2, 0.3, 0.3.0, 0.4, 0.4.0, 0.5.0, 0.5, 0.7.0, 0.7, 0.8.0, 0.8",
"unsupported version: '1'. Supported versions: 0, 0.2, 0.2.0, 0.2.1, 0.2.2, 0.3, 0.3.0, 0.4, 0.4.0, 0.5.0, 0.5, 0.6.0, 0.6, 0.7.0, 0.7, 0.8.0, 0.8",
0,
0,
},
Expand Down
2 changes: 1 addition & 1 deletion v1_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ func TestInvalidTestcasesV1(t *testing.T) {
ValidationError{
"",
"publiccodeYmlVersion",
"unsupported version: '1'. Supported versions: 0, 0.2, 0.2.0, 0.2.1, 0.2.2, 0.3, 0.3.0, 0.4, 0.4.0, 0.5.0, 0.5, 0.7.0, 0.7, 0.8.0, 0.8",
"unsupported version: '1'. Supported versions: 0, 0.2, 0.2.0, 0.2.1, 0.2.2, 0.3, 0.3.0, 0.4, 0.4.0, 0.5.0, 0.5, 0.6.0, 0.6, 0.7.0, 0.7, 0.8.0, 0.8",
0,
0,
},
Expand Down
Loading