Skip to content

Commit

Permalink
Test the file path handling.
Browse files Browse the repository at this point in the history
Signed-off-by: Ernst von Oelsen <[email protected]>
  • Loading branch information
ernstvonoelsen committed Jan 29, 2025
1 parent d6fbd0e commit 04ac63b
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions pkg/files/file_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// Copyright 2024 The Carvel Authors.
// SPDX-License-Identifier: Apache-2.0

package files_test

import (
"carvel.dev/ytt/pkg/files"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"testing"
)

func TestNewSortedFilesFromPaths(t *testing.T) {
inputPaths := []string{
"../yamltemplate/filetests/def.tpltest",
"https://example.org/test.yaml?hello=world&foo=bar",
"an/overwritten/path/to/file.yaml=https://example.org/test.yaml?hello=world&foo=bar"}
filesToProcess, err := files.NewSortedFilesFromPaths(inputPaths, files.SymlinkAllowOpts{true, []string{}})

require.NoError(t, err)

assert.Equal(t, filesToProcess[0].RelativePath(), "def.tpltest")
assert.Equal(t, filesToProcess[1].RelativePath(), "test.yaml")
assert.Equal(t, filesToProcess[1].Description(), "HTTP URL 'https://example.org/test.yaml?hello=world&foo=bar'")
assert.Equal(t, filesToProcess[2].RelativePath(), "an/overwritten/path/to/file.yaml")
assert.Equal(t, filesToProcess[2].Description(), "HTTP URL 'https://example.org/test.yaml?hello=world&foo=bar'")
}

0 comments on commit 04ac63b

Please sign in to comment.