Thanks to visit codestin.com
Credit goes to github.com

Skip to content
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
test: simple unit test for file functions
  • Loading branch information
Emyrk committed Apr 16, 2025
commit 0977c519a48b05e589d15c687fc42a1c83dfdc66
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