Files
Gokapi/internal/models/FileList_test.go
2022-02-24 14:53:02 +01:00

34 lines
1.2 KiB
Go

//go:build test
// +build test
package models
import (
"github.com/forceu/gokapi/internal/test"
"testing"
)
func TestToJsonResult(t *testing.T) {
file := File{
Id: "testId",
Name: "testName",
Size: "10 B",
SHA256: "sha256",
ExpireAt: 50,
ExpireAtString: "future",
DownloadsRemaining: 1,
PasswordHash: "pwhash",
HotlinkId: "hotlinkid",
ContentType: "text/html",
AwsBucket: "test",
Encryption: EncryptionInfo{
IsEncrypted: true,
DecryptionKey: []byte{0x01},
Nonce: []byte{0x02},
},
UnlimitedDownloads: true,
UnlimitedTime: true,
}
test.IsEqualString(t, file.ToJsonResult("serverurl/"), `{"Result":"OK","FileInfo":{"Id":"testId","Name":"testName","Size":"10 B","SHA256":"sha256","ExpireAt":50,"ExpireAtString":"future","DownloadsRemaining":1,"PasswordHash":"pwhash","HotlinkId":"hotlinkid","ContentType":"text/html","AwsBucket":"test","Encryption":{"IsEncrypted":true,"DecryptionKey":"AQ==","Nonce":"Ag=="},"UnlimitedDownloads":true,"UnlimitedTime":true},"Url":"serverurl/d?id=","HotlinkUrl":"serverurl/hotlink/"}`)
}