mirror of
https://github.com/TECHNOFAB11/jsonnet-bundler.git
synced 2025-12-12 08:00:05 +01:00
feat(spec): version field (#85)
Adds a `version` field to the `jsonnetfile.json`, so that `jb` can automatically recognize too old / too new schema versions, instead of panicking.
This commit is contained in:
parent
efe0c9e864
commit
bcd89fd33d
23 changed files with 454 additions and 102 deletions
80
spec/v1/deps/dependencies_test.go
Normal file
80
spec/v1/deps/dependencies_test.go
Normal file
|
|
@ -0,0 +1,80 @@
|
|||
// Copyright 2018 jsonnet-bundler authors
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
package deps
|
||||
|
||||
import (
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestParseDependency(t *testing.T) {
|
||||
const testFolder = "test/jsonnet/foobar"
|
||||
err := os.MkdirAll(testFolder, os.ModePerm)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer os.RemoveAll("test")
|
||||
|
||||
tests := []struct {
|
||||
name string
|
||||
path string
|
||||
want *Dependency
|
||||
}{
|
||||
{
|
||||
name: "Empty",
|
||||
path: "",
|
||||
want: nil,
|
||||
},
|
||||
{
|
||||
name: "Invalid",
|
||||
path: "example.com/foo",
|
||||
want: nil,
|
||||
},
|
||||
{
|
||||
name: "InvalidDomain",
|
||||
path: "example.c/foo/bar",
|
||||
want: nil,
|
||||
},
|
||||
{
|
||||
name: "InvalidDomain2",
|
||||
path: "examplec/foo/bar",
|
||||
want: nil,
|
||||
},
|
||||
{
|
||||
name: "local",
|
||||
path: testFolder,
|
||||
want: &Dependency{
|
||||
Source: Source{
|
||||
LocalSource: &Local{
|
||||
Directory: "test/jsonnet/foobar",
|
||||
},
|
||||
},
|
||||
Version: "",
|
||||
},
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
_ = t.Run(tt.name, func(t *testing.T) {
|
||||
dependency := Parse("", tt.path)
|
||||
|
||||
if tt.path == "" {
|
||||
assert.Nil(t, dependency)
|
||||
} else {
|
||||
assert.Equal(t, tt.want, dependency)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue