Fix: vela top cannot switch the theme (#5745)

Signed-off-by: howieyuen <howieyuen@outlook.com>
This commit is contained in:
howieyuen
2023-03-28 13:50:00 +08:00
committed by GitHub
parent d06d3bee79
commit 8619f1c413
2 changed files with 11 additions and 1 deletions

View File

@@ -291,7 +291,7 @@ func makeThemeConfigFileIfNotExist() bool {
if _, err := os.Open(filepath.Clean(themeConfigFilePath)); err != nil {
if os.IsNotExist(err) {
// make file if not exist
_ = os.MkdirAll(filepath.Clean(velaThemeHome), 0600)
_ = os.MkdirAll(filepath.Clean(velaThemeHome), 0700)
_ = os.WriteFile(filepath.Clean(themeConfigFilePath), []byte("name : "+DefaultTheme), 0600)
}
return false

View File

@@ -17,6 +17,8 @@ limitations under the License.
package config
import (
"os"
"strings"
"testing"
"github.com/gdamore/tcell/v2"
@@ -35,3 +37,11 @@ func TestColor(t *testing.T) {
c2 := Color("red")
assert.Equal(t, c2.Color(), tcell.GetColor("red").TrueColor())
}
func TestPersistentThemeConfig(t *testing.T) {
defer PersistentThemeConfig(DefaultTheme)
PersistentThemeConfig("foo")
bytes, err := os.ReadFile(themeConfigFilePath)
assert.Nil(t, err)
assert.True(t, strings.Contains(string(bytes), "foo"))
}