mirror of
https://github.com/IceWhaleTech/CasaOS.git
synced 2025-11-07 07:09:46 +00:00
wip
This commit is contained in:
parent
3dc1e454d5
commit
99127b2088
@ -1,13 +1,29 @@
|
|||||||
package command
|
package command
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"path/filepath"
|
"os"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/IceWhaleTech/CasaOS-Common/utils/constants"
|
"gotest.tools/assert"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestExecutePostStartScripts(t *testing.T) {
|
func TestExecuteScripts(t *testing.T) {
|
||||||
scriptDirectory := filepath.Join(constants.DefaultConfigPath, "start.d")
|
// make a temp directory
|
||||||
ExecuteScripts(scriptDirectory)
|
tmpDir, err := os.MkdirTemp("", "casaos-test-*")
|
||||||
|
assert.NilError(t, err)
|
||||||
|
defer os.RemoveAll(tmpDir)
|
||||||
|
|
||||||
|
ExecuteScripts(tmpDir)
|
||||||
|
|
||||||
|
// create a sample script under tmpDir
|
||||||
|
script := tmpDir + "/test.sh"
|
||||||
|
f, err := os.Create(script)
|
||||||
|
assert.NilError(t, err)
|
||||||
|
defer f.Close()
|
||||||
|
|
||||||
|
// write a sample script
|
||||||
|
_, err = f.WriteString("#!/bin/bash\necho 123")
|
||||||
|
assert.NilError(t, err)
|
||||||
|
|
||||||
|
ExecuteScripts(tmpDir)
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user