mirror of
https://github.com/go-task/task.git
synced 2025-06-23 00:38:19 +02:00
feat(remote): support include git remote (#1652)
This commit is contained in:
75
taskfile/node_git_test.go
Normal file
75
taskfile/node_git_test.go
Normal file
@ -0,0 +1,75 @@
|
||||
package taskfile
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestGitNode_ssh(t *testing.T) {
|
||||
node, err := NewGitNode("git@github.com:foo/bar.git//Taskfile.yml?ref=main", "", false)
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, "main", node.ref)
|
||||
assert.Equal(t, "Taskfile.yml", node.path)
|
||||
assert.Equal(t, "ssh://git@github.com/foo/bar.git//Taskfile.yml?ref=main", node.rawUrl)
|
||||
assert.Equal(t, "ssh://git@github.com/foo/bar.git", node.URL.String())
|
||||
entrypoint, err := node.ResolveEntrypoint("common.yml")
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, "ssh://git@github.com/foo/bar.git//common.yml?ref=main", entrypoint)
|
||||
}
|
||||
|
||||
func TestGitNode_sshWithDir(t *testing.T) {
|
||||
node, err := NewGitNode("git@github.com:foo/bar.git//directory/Taskfile.yml?ref=main", "", false)
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, "main", node.ref)
|
||||
assert.Equal(t, "directory/Taskfile.yml", node.path)
|
||||
assert.Equal(t, "ssh://git@github.com/foo/bar.git//directory/Taskfile.yml?ref=main", node.rawUrl)
|
||||
assert.Equal(t, "ssh://git@github.com/foo/bar.git", node.URL.String())
|
||||
entrypoint, err := node.ResolveEntrypoint("common.yml")
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, "ssh://git@github.com/foo/bar.git//directory/common.yml?ref=main", entrypoint)
|
||||
}
|
||||
|
||||
func TestGitNode_https(t *testing.T) {
|
||||
node, err := NewGitNode("https://github.com/foo/bar.git//Taskfile.yml?ref=main", "", false)
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, "main", node.ref)
|
||||
assert.Equal(t, "Taskfile.yml", node.path)
|
||||
assert.Equal(t, "https://github.com/foo/bar.git//Taskfile.yml?ref=main", node.rawUrl)
|
||||
assert.Equal(t, "https://github.com/foo/bar.git", node.URL.String())
|
||||
entrypoint, err := node.ResolveEntrypoint("common.yml")
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, "https://github.com/foo/bar.git//common.yml?ref=main", entrypoint)
|
||||
}
|
||||
|
||||
func TestGitNode_httpsWithDir(t *testing.T) {
|
||||
node, err := NewGitNode("https://github.com/foo/bar.git//directory/Taskfile.yml?ref=main", "", false)
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, "main", node.ref)
|
||||
assert.Equal(t, "directory/Taskfile.yml", node.path)
|
||||
assert.Equal(t, "https://github.com/foo/bar.git//directory/Taskfile.yml?ref=main", node.rawUrl)
|
||||
assert.Equal(t, "https://github.com/foo/bar.git", node.URL.String())
|
||||
entrypoint, err := node.ResolveEntrypoint("common.yml")
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, "https://github.com/foo/bar.git//directory/common.yml?ref=main", entrypoint)
|
||||
}
|
||||
|
||||
func TestGitNode_FilenameAndDir(t *testing.T) {
|
||||
node, err := NewGitNode("https://github.com/foo/bar.git//directory/Taskfile.yml?ref=main", "", false)
|
||||
assert.NoError(t, err)
|
||||
filename, dir := node.FilenameAndLastDir()
|
||||
assert.Equal(t, "Taskfile.yml", filename)
|
||||
assert.Equal(t, "directory", dir)
|
||||
|
||||
node, err = NewGitNode("https://github.com/foo/bar.git//Taskfile.yml?ref=main", "", false)
|
||||
assert.NoError(t, err)
|
||||
filename, dir = node.FilenameAndLastDir()
|
||||
assert.Equal(t, "Taskfile.yml", filename)
|
||||
assert.Equal(t, ".", dir)
|
||||
|
||||
node, err = NewGitNode("https://github.com/foo/bar.git//multiple/directory/Taskfile.yml?ref=main", "", false)
|
||||
assert.NoError(t, err)
|
||||
filename, dir = node.FilenameAndLastDir()
|
||||
assert.Equal(t, "Taskfile.yml", filename)
|
||||
assert.Equal(t, "directory", dir)
|
||||
}
|
Reference in New Issue
Block a user