Skip to content

Commit

Permalink
add test for PinSource sorting
Browse files Browse the repository at this point in the history
License: MIT
Signed-off-by: Jakub Sztandera <[email protected]>
  • Loading branch information
Kubuxu committed Oct 18, 2017
1 parent a6ec74a commit deec07d
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions pin/gc/gc_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package gc

import (
"testing"

"github.com/ipfs/go-ipfs/pin"
)

func TestPinSources(t *testing.T) {
gc := &gctype{}
sources := []pin.PinSource{
pin.PinSource{Direct: true},
pin.PinSource{Internal: true},
pin.PinSource{Strict: true},
pin.PinSource{},
}
err := gc.AddPinSource(sources...)
if err != nil {
t.Fatal(err)
}

p := gc.roots[0]
if !p.Strict {
t.Errorf("first root should be strict, was %v", p)
}
p = gc.roots[1]
if p.Strict || p.Direct || p.Internal {
t.Errorf("second root should be normal, was %v", p)
}
p = gc.roots[2]
if !p.Direct {
t.Errorf("third root should be direct, was %v", p)
}
p = gc.roots[3]
if !p.Internal {
t.Errorf("fourth root should be internal, was %v", p)
}

}

0 comments on commit deec07d

Please sign in to comment.