Encode the APIs, decode the APIs and check they are identical with the pre-encoded.
(t *testing.T)
| 44 | // Encode the APIs, decode the APIs and check they are identical with the |
| 45 | // pre-encoded. |
| 46 | func TestEncodeDecode(t *testing.T) { |
| 47 | ctx := log.Testing(t) |
| 48 | |
| 49 | apis, mappings := resolveAPIs(ctx) |
| 50 | |
| 51 | data, err := bapi.Encode(apis, mappings) |
| 52 | assert.For(ctx, "err").ThatError(err).Succeeded() |
| 53 | |
| 54 | decodedAPIs, decodedMappings, err := bapi.Decode(data) |
| 55 | assert.For(ctx, "err").ThatError(err).Succeeded() |
| 56 | |
| 57 | if assert.For(ctx, "num apis").That(len(decodedAPIs)).Equals(len(apis)) { |
| 58 | for i := range apis { |
| 59 | assert.For(ctx, "apis").That(decodedAPIs[i]).DeepEquals(apis[i]) |
| 60 | } |
| 61 | } |
| 62 | |
| 63 | if false { |
| 64 | // These tests are disabled because they currently do not pass. |
| 65 | // Mappings are being serialized, but their order is non-deterministic |
| 66 | // though the iteration of maps. |
| 67 | // TODO: Fix and enable these tests. |
| 68 | checkMappings(ctx, decodedAPIs, apis, decodedMappings, mappings) |
| 69 | } |
| 70 | } |
| 71 | |
| 72 | func checkMappings(ctx context.Context, |
| 73 | gotAPIs, expectAPIs []*semantic.API, |
nothing calls this directly
no test coverage detected