You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If I would like to define a Go test class to test it, then I can't access the assets var
package template_test
import (
"os"
"fmt"
"github.com/shurcooL/httpfs/vfsutil"
"testing"
"github.com/snowdrop/k8s-supervisor/pkg/template"
"net/http"
)
var (
templateFiles []string
project = "simple"
)
func TestVfsSimpleJavaProject(t *testing.T) {
tExpectedFiles := []string {
"simple/pom.xml",
"simple/src/main/java/dummy/DemoApplication.java",
"simple/src/main/resources/application.properties",
}
tFiles := walkTree()
for i := range tExpectedFiles {
if tExpectedFiles[i] != tFiles[i] {
t.Errorf("Template was incorrect, got: '%s', want: '%s'.", tFiles[i], tExpectedFiles[i])
}
}
}
func walkTree() []string {
var fs http.FileSystem = template.assets
...
Error:
go test pkg/template/template_java_test.go -v
# command-line-arguments_test
pkg/template/template_java_test.go:35:27: cannot refer to unexported name template.assets
pkg/template/template_java_test.go:35:27: undefined: template.assets
Is there a workaround ?
The text was updated successfully, but these errors were encountered:
If you want your assets variable to be accessible outside the template package, you need to make it exported, i.e., Assets.
If all you want is to be able to access assets from the template package tests, you could use internal tests rather than external. In other words, change package template_test to package template and access the assets variable directly. See https://golang.org/cmd/go/#hdr-Test_packages for more info about Go tests.
The
assets
var populated within a generated vfs go file can only be accessed within the same packageGenerated file name is :
vfsdata.go
If I would like to define a Go test class to test it, then I can't access the
assets
varError:
Is there a workaround ?
The text was updated successfully, but these errors were encountered: