Matthew Rich
bcf4e768ff
WIP: add support container image build using local filesytem contexts or contextes generated from resource definitions WIP: added support for the create command in the exec resource Fix a type matching error in `types` package use of generics
40 lines
859 B
Go
40 lines
859 B
Go
// Copyright 2024 Matthew Rich <matthewrich.conf@gmail.com>. All rights reserved.
|
|
|
|
package transport
|
|
|
|
import (
|
|
"github.com/stretchr/testify/assert"
|
|
"testing"
|
|
"fmt"
|
|
"os"
|
|
"net/url"
|
|
"path/filepath"
|
|
)
|
|
|
|
var TransportFileTestFile = fmt.Sprintf("%s/foo", TempDir)
|
|
|
|
func TestNewTransportFileReader(t *testing.T) {
|
|
path := fmt.Sprintf("%s/foo", TempDir)
|
|
u, e := url.Parse(fmt.Sprintf("file://%s", path))
|
|
assert.Nil(t, e)
|
|
|
|
writeErr := os.WriteFile(path, []byte("test"), 0644)
|
|
assert.Nil(t, writeErr)
|
|
|
|
file, err := NewFile(u)
|
|
assert.Nil(t, err)
|
|
assert.Equal(t, file.Path(), path)
|
|
}
|
|
|
|
func TestNewTransportFileReaderExtension(t *testing.T) {
|
|
u, e := url.Parse(fmt.Sprintf("file://%s.yaml", TransportFileTestFile))
|
|
assert.Nil(t, e)
|
|
|
|
f := &File{
|
|
uri: u,
|
|
path: filepath.Join(u.Hostname(), u.Path),
|
|
}
|
|
f.extension()
|
|
assert.Equal(t, f.exttype, "yaml")
|
|
}
|