mirror of
https://github.com/sourcegraph/sourcegraph.git
synced 2026-02-06 18:51:59 +00:00
We have a nice pointers package now, so this PR just replaces some helper functions with that package.
39 lines
739 B
Go
39 lines
739 B
Go
package database
|
|
|
|
import (
|
|
"context"
|
|
"encoding/json"
|
|
"testing"
|
|
|
|
"github.com/sourcegraph/sourcegraph/internal/encryption"
|
|
)
|
|
|
|
func testEncryptionKeyID(key encryption.Key) string {
|
|
v, err := key.Version(context.Background())
|
|
if err != nil {
|
|
panic("why are you sending me a key with an exploding version??")
|
|
}
|
|
|
|
return v.JSON()
|
|
}
|
|
|
|
func assertJSONEqual(t *testing.T, want, got any) {
|
|
wantJ := asJSON(t, want)
|
|
gotJ := asJSON(t, got)
|
|
if wantJ != gotJ {
|
|
t.Errorf("Wanted %s, but got %s", wantJ, gotJ)
|
|
}
|
|
}
|
|
|
|
func jsonEqual(t *testing.T, a, b any) bool {
|
|
return asJSON(t, a) == asJSON(t, b)
|
|
}
|
|
|
|
func asJSON(t *testing.T, v any) string {
|
|
b, err := json.MarshalIndent(v, "", " ")
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
return string(b)
|
|
}
|