Skip to content

Commit

Permalink
refactor!: remove expansion of relative paths
Browse files Browse the repository at this point in the history
Don't expand the relative path of files, the parser should
just deal with parsing and validation.
  • Loading branch information
bfabio committed May 18, 2021
1 parent 2ca3410 commit 8e934df
Showing 1 changed file with 0 additions and 24 deletions.
24 changes: 0 additions & 24 deletions parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"path"
"path/filepath"
"reflect"
"strings"
"testing"
)

Expand Down Expand Up @@ -446,29 +445,6 @@ func TestDecodeValueErrorsRemote(t *testing.T) {
}
}

// Test that relative paths are turned into absolute paths.
func TestRelativePaths(t *testing.T) {
const remoteFile = "https://raw.githubusercontent.com/italia/18app/master/publiccode.yml"

var p *Parser
var err error

if p, err = NewParser(remoteFile); err != nil {
t.Errorf("Can't create parser for %s", remoteFile)
}
err = p.Parse()

if err != nil {
t.Errorf("Failed to parse remote file from %v: %v", remoteFile, err)
}

fmt.Println(p.PublicCode.Description["it"].Screenshots[0])
if ! strings.HasPrefix(p.PublicCode.Description["it"].Screenshots[0], "http://") ||
! strings.HasPrefix(p.PublicCode.Description["it"].Screenshots[0], "https://") {
t.Errorf("Relative path was not turned into absolute URL: %v", p.PublicCode.Description["it"].Screenshots[0])
}
}

func TestIsReachable(t *testing.T) {
var p Parser
p.DisableNetwork = true
Expand Down

0 comments on commit 8e934df

Please sign in to comment.