Skip to content

test: simple unit test for file functions #85

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions preview.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,9 @@ func Preview(ctx context.Context, input Input, dir fs.FS) (output *Output, diagn
// moduleSource is "" for a local module
p := parser.New(dir, "",
parser.OptionStopOnHCLError(false),
// Obviously prevent http downloads.
parser.OptionWithDownloads(false),
// Cached moules are sourced from a file on the host disk.
parser.OptionWithSkipCachedModules(true),
parser.OptionWithTFVarsPaths(varFiles...),
parser.OptionWithEvalHook(planHook),
Expand Down
10 changes: 10 additions & 0 deletions preview_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,16 @@ func Test_Extract(t *testing.T) {
unknownTags: []string{},
params: map[string]assertParam{},
},
{
name: "diskaccess",
dir: "diskaccess",
expTags: map[string]string{},
unknownTags: []string{},
params: map[string]assertParam{
"file": ap().
optVals("hello world", types.UnknownStringValue),
},
},
} {
t.Run(tc.name, func(t *testing.T) {
t.Parallel()
Expand Down
1 change: 1 addition & 0 deletions testdata/diskaccess/hello.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
hello world
26 changes: 26 additions & 0 deletions testdata/diskaccess/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
terraform {
required_providers {
coder = {
source = "coder/coder"
version = "2.4.0-pre0"
}
}
}


data "coder_parameter" "file" {
name = "file"
description = "Attempt to read some files."
type = "string"
order = 1

option {
name = "Local"
value = file("./hello.txt")
}

option {
name = "Outer"
value = file("../README.md")
}
}
Loading