52 lines
1.7 KiB
Go
52 lines
1.7 KiB
Go
|
|
package starnotify
|
||
|
|
|
||
|
|
import "testing"
|
||
|
|
|
||
|
|
import "b612.me/notify"
|
||
|
|
|
||
|
|
func TestGetFileTransferSummariesByKeyDefaults(t *testing.T) {
|
||
|
|
const clientKey = "file-transfer-public-client"
|
||
|
|
const serverKey = "file-transfer-public-server"
|
||
|
|
_ = DeleteClient(clientKey)
|
||
|
|
_ = DeleteServer(serverKey)
|
||
|
|
defer DeleteClient(clientKey)
|
||
|
|
defer DeleteServer(serverKey)
|
||
|
|
|
||
|
|
NewClient(clientKey)
|
||
|
|
NewServer(serverKey)
|
||
|
|
|
||
|
|
clientActive, err := GetClientFileTransferActiveSummaries(clientKey)
|
||
|
|
if err != nil {
|
||
|
|
t.Fatalf("GetClientFileTransferActiveSummaries failed: %v", err)
|
||
|
|
}
|
||
|
|
if len(clientActive.Send) != 0 || len(clientActive.Receive) != 0 {
|
||
|
|
t.Fatalf("client active summary should be empty: %+v", clientActive)
|
||
|
|
}
|
||
|
|
|
||
|
|
serverCompleted, err := GetServerFileTransferCompletedSummaries(serverKey)
|
||
|
|
if err != nil {
|
||
|
|
t.Fatalf("GetServerFileTransferCompletedSummaries failed: %v", err)
|
||
|
|
}
|
||
|
|
if len(serverCompleted.Send) != 0 || len(serverCompleted.Receive) != 0 {
|
||
|
|
t.Fatalf("server completed summary should be empty: %+v", serverCompleted)
|
||
|
|
}
|
||
|
|
|
||
|
|
clientLatest, err := GetClientFileTransferLatestByFileID(clientKey, "missing")
|
||
|
|
if err != nil {
|
||
|
|
t.Fatalf("GetClientFileTransferLatestByFileID failed: %v", err)
|
||
|
|
}
|
||
|
|
if len(clientLatest.Send) != 0 || len(clientLatest.Receive) != 0 {
|
||
|
|
t.Fatalf("client latest summary should be empty: %+v", clientLatest)
|
||
|
|
}
|
||
|
|
|
||
|
|
serverLatestQuery, err := GetServerFileTransferLatestByFileIDQuery(serverKey, "missing", notify.FileTransferSummaryQuery{
|
||
|
|
Scope: "scope-a",
|
||
|
|
})
|
||
|
|
if err != nil {
|
||
|
|
t.Fatalf("GetServerFileTransferLatestByFileIDQuery failed: %v", err)
|
||
|
|
}
|
||
|
|
if len(serverLatestQuery.Send) != 0 || len(serverLatestQuery.Receive) != 0 {
|
||
|
|
t.Fatalf("server latest query summary should be empty: %+v", serverLatestQuery)
|
||
|
|
}
|
||
|
|
}
|