mirror of
https://github.com/Kpa-clawbot/meshcore-analyzer.git
synced 2026-03-29 08:29:55 +00:00
test: fix env isolation and comment accuracy in channel key tests
Agent-Logs-Url: https://github.com/Kpa-clawbot/meshcore-analyzer/sessions/38b3e96f-861b-4929-8134-b1b9de39a7fc Co-authored-by: KpaBap <746025+KpaBap@users.noreply.github.com>
This commit is contained in:
committed by
KpaBap
parent
e0c2d37041
commit
7b97c532a1
@@ -537,14 +537,20 @@ func TestLoadChannelKeysMergePriority(t *testing.T) {
|
||||
dir := t.TempDir()
|
||||
cfgPath := filepath.Join(dir, "config.json")
|
||||
|
||||
// Create a rainbow file with one key
|
||||
// Create a rainbow file with two keys: #rainbow (unique) and #override (to be overridden)
|
||||
rainbowPath := filepath.Join(dir, "channel-rainbow.json")
|
||||
t.Setenv("CHANNEL_KEYS_PATH", rainbowPath)
|
||||
rainbow := map[string]string{
|
||||
"#rainbow": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
|
||||
"#override": "rainbow_value_should_be_overridden",
|
||||
}
|
||||
rainbowJSON, _ := json.Marshal(rainbow)
|
||||
os.WriteFile(rainbowPath, rainbowJSON, 0o644)
|
||||
rainbowJSON, err := json.Marshal(rainbow)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := os.WriteFile(rainbowPath, rainbowJSON, 0o644); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
cfg := &Config{
|
||||
HashChannels: []string{"General", "#override"},
|
||||
@@ -571,6 +577,7 @@ func TestLoadChannelKeysMergePriority(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestLoadChannelKeysHashChannelsNormalization(t *testing.T) {
|
||||
t.Setenv("CHANNEL_KEYS_PATH", "")
|
||||
dir := t.TempDir()
|
||||
cfgPath := filepath.Join(dir, "config.json")
|
||||
|
||||
@@ -600,6 +607,7 @@ func TestLoadChannelKeysHashChannelsNormalization(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestLoadChannelKeysSkipExplicit(t *testing.T) {
|
||||
t.Setenv("CHANNEL_KEYS_PATH", "")
|
||||
dir := t.TempDir()
|
||||
cfgPath := filepath.Join(dir, "config.json")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user