2
0
mirror of https://github.com/acepanel/panel.git synced 2026-02-04 18:27:13 +08:00

fix: tests

This commit is contained in:
耗子
2023-07-11 01:37:18 +08:00
parent b606431305
commit 8b31415f5c

View File

@@ -39,13 +39,11 @@ func (s *SystemHelperTestSuite) TestReadFile() {
func (s *SystemHelperTestSuite) TestRemoveFile() {
filePath := "/tmp/testfile"
defer os.Remove(filePath)
err := os.WriteFile(filePath, []byte("test data"), 0644)
s.Nil(err)
s.True(RemoveFile(filePath))
s.False(RemoveFile(filePath))
}
func (s *SystemHelperTestSuite) TestExecShell() {
@@ -88,5 +86,11 @@ func (s *SystemHelperTestSuite) TestChown() {
err := os.WriteFile(filePath, []byte("test data"), 0644)
s.Nil(err)
s.True(Chown(filePath, "runner", "runner"))
ExecShell("sudo useradd testuser")
ExecShell("sudo groupadd testgroup")
s.True(Chown(filePath, "testuser", "testgroup"))
ExecShell("sudo userdel testuser")
ExecShell("sudo groupdel testgroup")
}