func TestReposetAddGetDirFile(t *testing.T) {
    ctx := context.Background()

    ds := dstest.Mock()

    rps := NewReposetProps()

    rps.SetType("infostore")
    rps.SetKind("blog")
    rps.SetName("mytestblog")
    rps.SetCreatedAt(uint64(time.Now().Unix()))
    rps.SetMaxAreas(0)
    rps.SetMaxCats(0)
    rps.SetMaxDocs(50000000)

    sr, err := NewStoreRoot(ctx, ds, nil)
    if err != nil {
         t.Fatal(err)
    }

    rpsid, err := sr.AddProps("reposetprops", rps)
    if err != nil {
         t.Fatal(err)
    }

    rrpsid, err := sr.HasProps("reposetprops", rps)
    if err != nil {
         t.Fatal(err)
    }

    if rrpsid == nil {
         t.Fatal("added reposetprops does not exist.")
    }

    if rrpsid.String() != rpsid.String() {
        t.Fatal(fmt.Errorf("repoprops cid mismatch, expected %v found %v", rpsid.String(), rrpsid.String()))
    }

    // validate the bytes we wrote
    b, err := rps.Marshal()
    if err != nil {
        t.Fatal(err)
    }

    bb, size, err := sr.bytesFromFile("reposetprops", int64(len(b)))
    if err != nil {
         t.Fatal(err)
    }

    // assert size is as expected
    if size != int64(len(b)) {
        t.Fatal("size is incorrect")
    }

    // assert valid bytes
    if !bytes.Equal(bb, b) {
        t.Fatal("data read was different than data written")
    }

    // create repoprops from file in directory
    ri, err := sr.GetProps("reposetprops", rps)
    if err != nil {
         t.Fatal(err)
    }

    rps2, ok := ri.(ReposetProps)
    if !ok {
        t.Fatal("invalid return type, expected.")
    }

    // assert object from file content matches object we wrote
    if !rps.Equal(rps2) {
        t.Fatal("data read was different than data written")
    }
}
// Test Reposet DAG node Add/Get using Directory and File objects
Test Reposet DAG node Add/Get using Directory and File objects
// Test Reposet DAG node Add / Get using Directory and File objects
func TestReposetAddGetDirFile(t *testing.T) {
    ctx := context.Background()
    ds := dstest.Mock()
    rps := NewReposetProps()
    rps.SetType("infostore")
    rps.SetKind("blog")
    rps.SetName("mytestblog")
    rps.SetCreatedAt(uint64(time.Now().Unix()))
    rps.SetMaxAreas(0)
    rps.SetMaxCats(0)
    rps.SetMaxDocs(50000000)
    sr, err := NewStoreRoot(ctx, ds, nil)
    if err != nil {
         t.Fatal(err)
    }
    rpsid, err := sr.AddProps("reposetprops", rps)
    if err != nil {
         t.Fatal(err)
    }
    rrpsid, err := sr.HasProps("reposetprops", rps)
    if err != nil {
         t.Fatal(err)
    }
    if rrpsid == nil {
         t.Fatal("added reposetprops does not exist.")
    }
    if rrpsid.String() != rpsid.String() {
        t.Fatal(fmt.Errorf("repoprops cid mismatch, expected %v found %v", rpsid.String(), rrpsid.String()))
    }
    b, err := rps.Marshal()
    if err != nil {
        t.Fatal(err)
    }
    bb, size, err := sr.bytesFromFile("reposetprops", int64(len(b)))
    if err != nil {
         t.Fatal(err)
    }
    if size != int64(len(b)) {
        t.Fatal("size is incorrect")
    }
    if !bytes.Equal(bb, b) {
        t.Fatal("data read was different than data written")
    }
    ri, err := sr.GetProps("reposetprops", rps)
    if err != nil {
         t.Fatal(err)
    }
    rps2, ok := ri.(ReposetProps)
    if !ok {
        t.Fatal("invalid return type, expected.")
    }
    if !rps.Equal(rps2) {
        t.Fatal("data read was different than data written")
    }
}
func TestReposetAddGetDirFile ( t * testing . T ) { ctx := context . Background ( ) ds := dstest . Mock ( ) rps := NewReposetProps ( ) rps . SetType ( " " ) rps . SetKind ( " " ) rps . SetName ( " " ) rps . SetCreatedAt ( uint64 ( time . Now ( ) . Unix ( ) ) ) rps . SetMaxAreas ( 0 ) rps . SetMaxCats ( 0 ) rps . SetMaxDocs ( 50000000 ) sr , err := NewStoreRoot ( ctx , ds , nil ) if err != nil { t . Fatal ( err ) } rpsid , err := sr . AddProps ( " " , rps ) if err != nil { t . Fatal ( err ) } rrpsid , err := sr . HasProps ( " " , rps ) if err != nil { t . Fatal ( err ) } if rrpsid == nil { t . Fatal ( " " ) } if rrpsid . String ( ) != rpsid . String ( ) { t . Fatal ( fmt . Errorf ( " " , rpsid . String ( ) , rrpsid . String ( ) ) ) } b , err := rps . Marshal ( ) if err != nil { t . Fatal ( err ) } bb , size , err := sr . bytesFromFile ( " " , int64 ( len ( b ) ) ) if err != nil { t . Fatal ( err ) } if size != int64 ( len ( b ) ) { t . Fatal ( " " ) } if ! bytes . Equal ( bb , b ) { t . Fatal ( " " ) } ri , err := sr . GetProps ( " " , rps ) if err != nil { t . Fatal ( err ) } rps2 , ok := ri . ( ReposetProps ) if ! ok { t . Fatal ( " " ) } if ! rps . Equal ( rps2 ) { t . Fatal ( " " ) } }
Test Reposet DAG node Add/Get using Directory and File objects
Test Reposet DAG node Add / Get using Directory and File objects
// validate the bytes we wrote // assert size is as expected // assert valid bytes // create repoprops from file in directory // assert object from file content matches object we wrote