Skip to content
Snippets Groups Projects
Commit 61c6de9f authored by Maximilian Wilhelm's avatar Maximilian Wilhelm
Browse files

Add more tests for contributing ASNs.

parent 71458b44
No related branches found
No related tags found
No related merge requests found
...@@ -24,7 +24,7 @@ func TestFancy(t *testing.T) { ...@@ -24,7 +24,7 @@ func TestFancy(t *testing.T) {
{ {
runCmd: func() { c.Add(41981) }, runCmd: func() { c.Add(41981) },
expect: func() bool { return c.IsContributingASN(41981) }, expect: func() bool { return c.IsContributingASN(41981) },
msg: "AS41981 should be contributing", msg: "AS41981 should be contributing.",
}, },
{ {
runCmd: func() { c.Remove(41981) }, runCmd: func() { c.Remove(41981) },
...@@ -36,30 +36,49 @@ func TestFancy(t *testing.T) { ...@@ -36,30 +36,49 @@ func TestFancy(t *testing.T) {
{ {
runCmd: func() { c.Add(41981) }, runCmd: func() { c.Add(41981) },
expect: func() bool { return c.IsContributingASN(41981) }, expect: func() bool { return c.IsContributingASN(41981) },
msg: "AS41981 should be contributing", msg: "AS41981 should be contributing.",
}, },
{ {
runCmd: func() { c.Add(201701) }, runCmd: func() { c.Add(201701) },
expect: func() bool { return c.IsContributingASN(41981) }, expect: func() bool { return c.IsContributingASN(41981) },
msg: "AS201701 should be contributing", msg: "AS201701 should be contributing.",
}, },
// Add AS41981 2nd time // Add AS41981 2nd time
{ {
runCmd: func() { c.Add(41981) }, runCmd: func() { c.Add(41981) },
expect: func() bool { return c.IsContributingASN(41981) }, expect: func() bool { return c.IsContributingASN(41981) },
msg: "AS41981 should be still contributing", msg: "AS41981 should be still contributing.",
}, },
{ {
runCmd: func() {}, runCmd: func() {},
expect: func() bool { return c.contributingASNs[0].asn == 41981 }, expect: func() bool { return c.contributingASNs[0].asn == 41981 },
msg: "AS41981 is first ASN in list", msg: "AS41981 is first ASN in list.",
}, },
{ {
runCmd: func() { fmt.Printf("%+v", c.contributingASNs) }, runCmd: func() { fmt.Printf("%+v", c.contributingASNs) },
expect: func() bool { return c.contributingASNs[0].count == 2 }, expect: func() bool { return c.contributingASNs[0].count == 2 },
msg: "AS41981 should be present twice.", msg: "AS41981 should be present twice.",
}, },
// Remove 2nd AS41981
{
runCmd: func() { c.Remove(41981) },
expect: func() bool { return c.IsContributingASN(41981) },
msg: "AS41981 should still be contributing.",
},
{
runCmd: func() {},
expect: func() bool { return c.contributingASNs[0].count == 1 },
msg: "S41981 should be present once.",
},
// Remove AS201701
{
runCmd: func() { c.Remove(201701) },
expect: func() bool { return !c.IsContributingASN(201701) },
msg: "AS201701 shouldn't be contributing no more.",
},
} }
for i, test := range tests { for i, test := range tests {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment