MCPcopy Index your code
hub / github.com/perkeep/perkeep / TestWriteKeyRing

Function TestWriteKeyRing

pkg/jsonsign/jsonsign_test.go:205–228  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

203}
204
205func TestWriteKeyRing(t *testing.T) {
206 ent, err := EntityFromSecring("26F5ABDA", "testdata/test-secring.gpg")
207 if err != nil {
208 t.Fatalf("NewEntity: %v", err)
209 }
210 var buf bytes.Buffer
211 err = WriteKeyRing(&buf, openpgp.EntityList([]*openpgp.Entity{ent}))
212 if err != nil {
213 t.Fatalf("WriteKeyRing: %v", err)
214 }
215
216 el, err := openpgp.ReadArmoredKeyRing(&buf)
217 if err != nil {
218 t.Fatalf("ReadKeyRing: %v", err)
219 }
220 if len(el) != 1 {
221 t.Fatalf("ReadKeyRing read %d entities; want 1", len(el))
222 }
223 orig := entityString(ent)
224 got := entityString(el[0])
225 if orig != got {
226 t.Fatalf("original vs. wrote-then-read entities differ:\norig: %s\n got: %s", orig, got)
227 }
228}
229
230// stupid entity stringier for testing.
231func entityString(ent *openpgp.Entity) string {

Callers

nothing calls this directly

Calls 4

EntityFromSecringFunction · 0.85
WriteKeyRingFunction · 0.85
entityStringFunction · 0.85
FatalfMethod · 0.65

Tested by

no test coverage detected