aboutsummaryrefslogtreecommitdiff
path: root/rules_manager_test.go
diff options
context:
space:
mode:
authorEmiliano Ciavatta2020-10-16 17:06:05 +0000
committerEmiliano Ciavatta2020-10-16 17:06:05 +0000
commit56f70a72196c777f248038bb2e2e4099e6e1367d (patch)
tree714ad5aed8698dfffbb472b3fa74909acb8cdead /rules_manager_test.go
parent6204c99e69d1707a79c5e56685b47310106c60b0 (diff)
parent79b8b2fa3e8563c986da8baa3a761f2d4f0c6f47 (diff)
Merge branch 'develop'
Diffstat (limited to 'rules_manager_test.go')
-rw-r--r--rules_manager_test.go32
1 files changed, 26 insertions, 6 deletions
diff --git a/rules_manager_test.go b/rules_manager_test.go
index a2ec501..215e601 100644
--- a/rules_manager_test.go
+++ b/rules_manager_test.go
@@ -1,3 +1,20 @@
+/*
+ * This file is part of caronte (https://github.com/eciavatta/caronte).
+ * Copyright (c) 2020 Emiliano Ciavatta.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, version 3.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
package main
import (
@@ -14,7 +31,8 @@ func TestAddAndGetAllRules(t *testing.T) {
rulesManager, err := LoadRulesManager(wrapper.Storage, "FLAG{test}")
require.NoError(t, err)
impl := rulesManager.(*rulesManagerImpl)
- checkVersion(t, rulesManager, impl.rulesByName["flag"].ID)
+ checkVersion(t, rulesManager, impl.rulesByName["flag_out"].ID)
+ checkVersion(t, rulesManager, impl.rulesByName["flag_in"].ID)
emptyRule := Rule{Name: "empty", Color: "#fff", Enabled: true}
emptyID, err := rulesManager.AddRule(wrapper.Context, emptyRule)
assert.NoError(t, err)
@@ -103,8 +121,8 @@ func TestAddAndGetAllRules(t *testing.T) {
assert.Equal(t, expected, impl.rulesByName[expected.Name])
}
- assert.Len(t, impl.rules, 5)
- assert.Len(t, impl.rulesByName, 5)
+ assert.Len(t, impl.rules, 6)
+ assert.Len(t, impl.rulesByName, 6)
assert.Len(t, impl.patterns, 5)
assert.Len(t, impl.patternsIds, 5)
@@ -118,8 +136,9 @@ func TestAddAndGetAllRules(t *testing.T) {
checkRule(rule2, []int{2, 3})
checkRule(rule3, []int{3, 4})
- assert.Len(t, rulesManager.GetRules(), 5)
- assert.ElementsMatch(t, []Rule{impl.rulesByName["flag"], emptyRule, rule1, rule2, rule3}, rulesManager.GetRules())
+ assert.Len(t, rulesManager.GetRules(), 6)
+ assert.ElementsMatch(t, []Rule{impl.rulesByName["flag_out"], impl.rulesByName["flag_in"], emptyRule,
+ rule1, rule2, rule3}, rulesManager.GetRules())
wrapper.Destroy(t)
}
@@ -193,7 +212,8 @@ func TestFillWithMatchedRules(t *testing.T) {
rulesManager, err := LoadRulesManager(wrapper.Storage, "FLAG{test}")
require.NoError(t, err)
impl := rulesManager.(*rulesManagerImpl)
- checkVersion(t, rulesManager, impl.rulesByName["flag"].ID)
+ checkVersion(t, rulesManager, impl.rulesByName["flag_out"].ID)
+ checkVersion(t, rulesManager, impl.rulesByName["flag_in"].ID)
emptyRule, err := rulesManager.AddRule(wrapper.Context, Rule{Name: "empty", Color: "#fff"})
require.NoError(t, err)