github.com/anishathalye/periscope@v0.3.5/internal/periscope/forget_test.go (about)

     1  package periscope
     2  
     3  import (
     4  	"github.com/anishathalye/periscope/internal/testfs"
     5  
     6  	"testing"
     7  )
     8  
     9  func TestForgetBasic(t *testing.T) {
    10  	fs := testfs.Read(`
    11  /d1/a [1024 1]
    12  /d1/b [1234 2]
    13  /d2/a [1024 1]
    14  /d2/b [1234 2]
    15  /d3/a [1024 1]
    16  	`).Mkfs()
    17  	ps, _, _ := newTest(fs)
    18  	err := ps.Scan([]string{"/"}, &ScanOptions{})
    19  	check(t, err)
    20  	infos, _ := ps.db.Lookup("/d1/a")
    21  	if len(infos) != 3 {
    22  		t.Fatal("expected 3 infos")
    23  	}
    24  	err = ps.Forget([]string{"/d2"}, &ForgetOptions{})
    25  	check(t, err)
    26  	infos, _ = ps.db.Lookup("/d1/a")
    27  	if len(infos) != 2 {
    28  		t.Fatal("expected 2 infos")
    29  	}
    30  	infos, _ = ps.db.Lookup("/d2/a")
    31  	if len(infos) != 0 {
    32  		t.Fatal("expected 0 infos")
    33  	}
    34  	infos, _ = ps.db.Lookup("/d1/b")
    35  	if len(infos) != 1 {
    36  		t.Fatal("expected 1 info")
    37  	}
    38  }