@@ -11,6 +11,7 @@ import (
1111 "fmt"
1212 "net/http"
1313 "testing"
14+ "time"
1415
1516 "github.com/google/go-cmp/cmp"
1617)
@@ -205,3 +206,57 @@ func TestGPGEmail_Marshal(t *testing.T) {
205206
206207 testJSONMarshal (t , u , want )
207208}
209+
210+ func TestGPGKey_Marshal (t * testing.T ) {
211+ testJSONMarshal (t , & GPGKey {}, "{}" )
212+
213+ ti := & time.Time {}
214+
215+ g := & GPGKey {
216+ ID : Int64 (1 ),
217+ PrimaryKeyID : Int64 (1 ),
218+ KeyID : String ("someKeyID" ),
219+ RawKey : String ("someRawKeyID" ),
220+ PublicKey : String ("somePublicKey" ),
221+ Emails : []* GPGEmail {
222+ {
223+ Email : String ("someEmail" ),
224+ Verified : Bool (true ),
225+ },
226+ },
227+ Subkeys : []* GPGKey {
228+ {},
229+ },
230+ CanSign : Bool (true ),
231+ CanEncryptComms : Bool (true ),
232+ CanEncryptStorage : Bool (true ),
233+ CanCertify : Bool (true ),
234+ CreatedAt : ti ,
235+ ExpiresAt : ti ,
236+ }
237+
238+ want := `{
239+ "id":1,
240+ "primary_key_id":1,
241+ "key_id":"someKeyID",
242+ "raw_key":"someRawKeyID",
243+ "public_key":"somePublicKey",
244+ "emails":[
245+ {
246+ "email":"someEmail",
247+ "verified":true
248+ }
249+ ],
250+ "subkeys":[
251+ {}
252+ ],
253+ "can_sign":true,
254+ "can_encrypt_comms":true,
255+ "can_encrypt_storage":true,
256+ "can_certify":true,
257+ "created_at":"0001-01-01T00:00:00Z",
258+ "expires_at":"0001-01-01T00:00:00Z"
259+ }`
260+
261+ testJSONMarshal (t , g , want )
262+ }
0 commit comments