ppforge/cop/collection_test.go

60 lines
1.1 KiB
Go

package cop
import (
"fmt"
"os"
"path"
"testing"
)
func TestOpen(t *testing.T) {
fcop := FileCOP{}
wd, err := os.Getwd()
if err != nil {
fmt.Printf("Os error: %s", err)
t.Fail()
}
fcop.Open(path.Join(wd, "..", "test", "cop"))
l, err := fcop.Protocols()
if err != nil {
t.Fail()
}
for k, v := range fcop.protocols {
fmt.Printf("%s->%s\n", k, v.Path)
}
for _, pce := range l {
fmt.Printf("%s//%s\n", pce.Path, pce.Protocol.Name)
}
}
func TestClosed(t *testing.T) {
fcop := FileCOP{}
wd, err := os.Getwd()
if err != nil {
fmt.Printf("Os error: %s", err)
t.Fail()
}
fcop.Open(path.Join(wd, "..", "test", "cop"))
fcop.Close()
l, err := fcop.Protocols()
if err == nil || l != nil {
fmt.Println("Protocols did not deliver error")
t.Fail()
}
err = fcop.Add(nil)
if err == nil {
fmt.Println("Add did not deliver error")
t.Fail()
}
err = fcop.Update(nil)
if err == nil {
fmt.Println("Update did not deliver error")
t.Fail()
}
err = fcop.Sync()
if err == nil {
fmt.Println("UpdateCollection did not deliver error")
t.Fail()
}
}