add plain test
This commit is contained in:
parent
8ef78c3d5d
commit
454820f6d6
5 changed files with 52 additions and 1 deletions
25
file_test.go
25
file_test.go
|
@ -7,7 +7,7 @@ import (
|
|||
"git.bivouac.wiki/go/bloat"
|
||||
)
|
||||
|
||||
func TestFile(t *testing.T) {
|
||||
func TestEncFile(t *testing.T) {
|
||||
type txttype struct {
|
||||
Abc int
|
||||
Test bool
|
||||
|
@ -30,3 +30,26 @@ func TestFile(t *testing.T) {
|
|||
}
|
||||
|
||||
}
|
||||
func TestPlainFile(t *testing.T) {
|
||||
type txttype struct {
|
||||
Abc int
|
||||
Test bool
|
||||
}
|
||||
recip, err := bloat.NewPlainBloat[txttype]()
|
||||
sender, err := bloat.NewPlainBloat[txttype]()
|
||||
plaindata := txttype{Abc: 100, Test: true}
|
||||
data, err := sender.WritePlain(plaindata, recip)
|
||||
err = os.WriteFile("test/plain.txttype.bloat", data, 0664)
|
||||
if err != nil {
|
||||
t.Errorf("writing failed")
|
||||
}
|
||||
content, err := os.ReadFile("test/plain.txttype.bloat")
|
||||
dec, err := recip.ReadPlain(content, sender)
|
||||
if dec.Test != plaindata.Test {
|
||||
t.Errorf("not equal")
|
||||
}
|
||||
if dec.Abc != plaindata.Abc {
|
||||
t.Errorf("not equal")
|
||||
}
|
||||
|
||||
}
|
||||
|
|
5
types/carrier.go
Normal file
5
types/carrier.go
Normal file
|
@ -0,0 +1,5 @@
|
|||
package types
|
||||
|
||||
type Carrier struct {
|
||||
Addr string `xml:"Addr"`
|
||||
}
|
14
types/phish.go
Normal file
14
types/phish.go
Normal file
|
@ -0,0 +1,14 @@
|
|||
package types
|
||||
|
||||
import (
|
||||
"aead.dev/minisign"
|
||||
"filippo.io/age"
|
||||
)
|
||||
|
||||
type BloatPhishXML struct {
|
||||
AgePub age.X25519Recipient
|
||||
MinisignPub minisign.PublicKey
|
||||
NS []BloatPhishXML
|
||||
Venue []Venue
|
||||
Carrier []Carrier
|
||||
}
|
4
types/potential.go
Normal file
4
types/potential.go
Normal file
|
@ -0,0 +1,4 @@
|
|||
package types
|
||||
|
||||
type Potential struct {
|
||||
}
|
5
types/venue.go
Normal file
5
types/venue.go
Normal file
|
@ -0,0 +1,5 @@
|
|||
package types
|
||||
|
||||
type Venue struct {
|
||||
Addr string `xml:"Addr"`
|
||||
}
|
Loading…
Add table
Reference in a new issue