mirror of
https://github.com/IceWhaleTech/CasaOS.git
synced 2025-11-06 22:59:44 +00:00
wip
This commit is contained in:
parent
3dc1e454d5
commit
99127b2088
@ -1,13 +1,29 @@
|
||||
package command
|
||||
|
||||
import (
|
||||
"path/filepath"
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
"github.com/IceWhaleTech/CasaOS-Common/utils/constants"
|
||||
"gotest.tools/assert"
|
||||
)
|
||||
|
||||
func TestExecutePostStartScripts(t *testing.T) {
|
||||
scriptDirectory := filepath.Join(constants.DefaultConfigPath, "start.d")
|
||||
ExecuteScripts(scriptDirectory)
|
||||
func TestExecuteScripts(t *testing.T) {
|
||||
// make a temp directory
|
||||
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