fix: ensure go tests have PLUGIN_ENABLED_PATH set
This commit is contained in:
1 parent
d803dbb84a
commit
96a2ec01f5
1 file changed
+14
-3
@@ -20,6 +20,10 @@ var (
|
|||||||
testEnvLine2 = "export testKey=TESTING"
|
testEnvLine2 = "export testKey=TESTING"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func setupTests() (err error) {
|
||||||
|
return os.Setenv("PLUGIN_ENABLED_PATH", "/var/lib/dokku/plugins/enabled")
|
||||||
|
}
|
||||||
|
|
||||||
func setupTestApp() (err error) {
|
func setupTestApp() (err error) {
|
||||||
Expect(os.MkdirAll(testAppDir, 0644)).To(Succeed())
|
Expect(os.MkdirAll(testAppDir, 0644)).To(Succeed())
|
||||||
b := []byte(testEnvLine + "\n")
|
b := []byte(testEnvLine + "\n")
|
||||||
@@ -48,32 +52,37 @@ func teardownTestApp2() {
|
|||||||
|
|
||||||
func TestCommonGetEnv(t *testing.T) {
|
func TestCommonGetEnv(t *testing.T) {
|
||||||
RegisterTestingT(t)
|
RegisterTestingT(t)
|
||||||
|
Expect(setupTests()).To(Succeed())
|
||||||
Expect(MustGetEnv("DOKKU_ROOT")).To(Equal("/home/dokku"))
|
Expect(MustGetEnv("DOKKU_ROOT")).To(Equal("/home/dokku"))
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestCommonGetAppImageRepo(t *testing.T) {
|
func TestCommonGetAppImageRepo(t *testing.T) {
|
||||||
RegisterTestingT(t)
|
RegisterTestingT(t)
|
||||||
|
Expect(setupTests()).To(Succeed())
|
||||||
Expect(GetAppImageRepo("testapp")).To(Equal("dokku/testapp"))
|
Expect(GetAppImageRepo("testapp")).To(Equal("dokku/testapp"))
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestCommonVerifyImageInvalid(t *testing.T) {
|
func TestCommonVerifyImageInvalid(t *testing.T) {
|
||||||
RegisterTestingT(t)
|
RegisterTestingT(t)
|
||||||
|
Expect(setupTests()).To(Succeed())
|
||||||
Expect(VerifyImage("testapp")).To(Equal(false))
|
Expect(VerifyImage("testapp")).To(Equal(false))
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestCommonVerifyAppNameInvalid(t *testing.T) {
|
func TestCommonVerifyAppNameInvalid(t *testing.T) {
|
||||||
RegisterTestingT(t)
|
RegisterTestingT(t)
|
||||||
err := VerifyAppName("1994testApp")
|
Expect(setupTests()).To(Succeed())
|
||||||
Expect(err).To(HaveOccurred())
|
Expect(VerifyAppName("1994testApp")).To(HaveOccurred())
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestCommonVerifyAppName(t *testing.T) {
|
func TestCommonVerifyAppName(t *testing.T) {
|
||||||
RegisterTestingT(t)
|
RegisterTestingT(t)
|
||||||
|
Expect(setupTests()).To(Succeed())
|
||||||
Expect(setupTestApp()).To(Succeed())
|
Expect(setupTestApp()).To(Succeed())
|
||||||
Expect(VerifyAppName(testAppName)).To(Succeed())
|
Expect(VerifyAppName(testAppName)).To(Succeed())
|
||||||
teardownTestApp()
|
teardownTestApp()
|
||||||
|
|
||||||
RegisterTestingT(t)
|
RegisterTestingT(t)
|
||||||
|
Expect(setupTests()).To(Succeed())
|
||||||
Expect(setupTestApp2()).To(Succeed())
|
Expect(setupTestApp2()).To(Succeed())
|
||||||
Expect(VerifyAppName(testAppName2)).To(Succeed())
|
Expect(VerifyAppName(testAppName2)).To(Succeed())
|
||||||
teardownTestApp2()
|
teardownTestApp2()
|
||||||
@@ -81,13 +90,14 @@ func TestCommonVerifyAppName(t *testing.T) {
|
|||||||
|
|
||||||
func TestCommonDokkuAppsError(t *testing.T) {
|
func TestCommonDokkuAppsError(t *testing.T) {
|
||||||
RegisterTestingT(t)
|
RegisterTestingT(t)
|
||||||
|
Expect(setupTests()).To(Succeed())
|
||||||
_, err := DokkuApps()
|
_, err := DokkuApps()
|
||||||
Expect(err).To(HaveOccurred())
|
Expect(err).To(HaveOccurred())
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestCommonDokkuApps(t *testing.T) {
|
func TestCommonDokkuApps(t *testing.T) {
|
||||||
RegisterTestingT(t)
|
RegisterTestingT(t)
|
||||||
os.Setenv("PLUGIN_ENABLED_PATH", "/var/lib/dokku/plugins/enabled")
|
Expect(setupTests()).To(Succeed())
|
||||||
Expect(setupTestApp()).To(Succeed())
|
Expect(setupTestApp()).To(Succeed())
|
||||||
apps, err := DokkuApps()
|
apps, err := DokkuApps()
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
@@ -98,6 +108,7 @@ func TestCommonDokkuApps(t *testing.T) {
|
|||||||
|
|
||||||
func TestCommonStripInlineComments(t *testing.T) {
|
func TestCommonStripInlineComments(t *testing.T) {
|
||||||
RegisterTestingT(t)
|
RegisterTestingT(t)
|
||||||
|
Expect(setupTests()).To(Succeed())
|
||||||
text := StripInlineComments(strings.Join([]string{testEnvLine, "# testing comment"}, " "))
|
text := StripInlineComments(strings.Join([]string{testEnvLine, "# testing comment"}, " "))
|
||||||
Expect(text).To(Equal(testEnvLine))
|
Expect(text).To(Equal(testEnvLine))
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user