generated from TBD54566975/tbd-project-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
scaffolder_test.go
34 lines (30 loc) · 1.09 KB
/
scaffolder_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package scaffolder_test
import (
"os"
"path/filepath"
"testing"
"github.com/alecthomas/assert/v2"
"github.com/block/scaffolder"
"github.com/block/scaffolder/scaffoldertest"
)
func TestScaffolder(t *testing.T) {
tmpDir := filepath.Join(t.TempDir(), "new")
err := scaffolder.Scaffold("testdata/template", tmpDir, map[string]any{
"List": []string{"first", "second"},
"Name": "test",
"Include": true,
}, scaffolder.Exclude("excluded"))
assert.NoError(t, err)
expect := []scaffoldertest.File{
{Name: "first.txt", Mode: 0o600, Content: "first"},
{Name: "first/first", Mode: 0o600},
{Name: "include", Mode: 0o600, Content: "included"},
{Name: "included-dir/included", Mode: 0o600, Content: "included"},
{Name: "intermediate", Mode: 0o700 | os.ModeSymlink, Content: "Hello, test!\n"},
{Name: "regular-test", Mode: 0o600, Content: "Hello, test!\n"},
{Name: "second.txt", Mode: 0o600, Content: "second"},
{Name: "second/second", Mode: 0o600},
{Name: "symlink-test", Mode: 0o700 | os.ModeSymlink, Content: "Hello, test!\n"},
}
scaffoldertest.AssertFilesEqual(t, tmpDir, expect)
}