@@ -2,9 +2,8 @@ package preview_test
22
33import (
44 "context"
5- "embed"
65 "fmt"
7- "io/fs "
6+ "os "
87 "path/filepath"
98 "testing"
109
@@ -16,16 +15,12 @@ import (
1615 "github.com/coder/preview/types"
1716)
1817
19- //go:embed testdata
20- var testdata embed.FS
21-
2218func Test_Extract (t * testing.T ) {
2319 t .Parallel ()
2420
2521 for _ , tc := range []struct {
2622 name string
2723 dir string
28- showJSON string
2924 failPreview bool
3025 input preview.Input
3126
@@ -122,21 +117,33 @@ func Test_Extract(t *testing.T) {
122117 expUnknowns : []string {
123118 "foo" , "bar" ,
124119 },
120+
125121 input : preview.Input {},
126122 params : map [string ]func (t * testing.T , parameter types.Parameter ){},
127123 },
128124 {
129- name : "external docker resource with plan data" ,
130- dir : "dockerdata" ,
131- showJSON : "show.json" ,
125+ name : "external docker resource with plan data" ,
126+ dir : "dockerdata" ,
132127 expTags : map [string ]string {
133128 "qux" : "quux" ,
134129 "foo" : "ubuntu@sha256:80dd3c3b9c6cecb9f1667e9290b3bc61b78c2678c02cbdae5f0fea92cc6734ab" ,
135130 "bar" : "centos@sha256:a27fd8080b517143cbbbab9dfb7c8571c40d67d534bbdee55bd6c473f432b177" ,
136131 },
137132 expUnknowns : []string {},
138- input : preview.Input {},
139- params : map [string ]func (t * testing.T , parameter types.Parameter ){},
133+ input : preview.Input {
134+ PlanJSONPath : "plan.json" ,
135+ },
136+ params : map [string ]func (t * testing.T , parameter types.Parameter ){},
137+ },
138+ {
139+ name : "external module with external data" ,
140+ dir : "module" ,
141+ expTags : map [string ]string {},
142+ expUnknowns : []string {},
143+ input : preview.Input {
144+ PlanJSONPath : "before.json" ,
145+ },
146+ params : map [string ]func (t * testing.T , parameter types.Parameter ){},
140147 },
141148 } {
142149 t .Run (tc .name , func (t * testing.T ) {
@@ -148,8 +155,9 @@ func Test_Extract(t *testing.T) {
148155 tc .expTags = map [string ]string {}
149156 }
150157
151- dirFs , err := fs .Sub (testdata , filepath .Join ("testdata" , tc .dir ))
152- require .NoError (t , err )
158+ dirFs := os .DirFS (filepath .Join ("testdata" , tc .dir ))
159+ //a, b := fs.ReadDir(dirFs, ".")
160+ //fmt.Println(a, b)
153161
154162 output , diags := preview .Preview (context .Background (), tc .input , dirFs )
155163 if tc .failPreview {
0 commit comments