{"id":15622758,"url":"https://github.com/nbaztec/protocmp","last_synced_at":"2025-03-29T16:27:56.012Z","repository":{"id":57541801,"uuid":"291427087","full_name":"nbaztec/protocmp","owner":"nbaztec","description":"A protobuf comparison library","archived":false,"fork":false,"pushed_at":"2020-09-04T21:58:56.000Z","size":303,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-02-04T17:28:21.430Z","etag":null,"topics":["assert","comparison","diff","equal","golang","protobuf","test"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nbaztec.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-08-30T08:05:44.000Z","updated_at":"2020-09-04T21:58:58.000Z","dependencies_parsed_at":"2022-09-09T02:50:32.133Z","dependency_job_id":null,"html_url":"https://github.com/nbaztec/protocmp","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nbaztec%2Fprotocmp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nbaztec%2Fprotocmp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nbaztec%2Fprotocmp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nbaztec%2Fprotocmp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nbaztec","download_url":"https://codeload.github.com/nbaztec/protocmp/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246210802,"owners_count":20741233,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["assert","comparison","diff","equal","golang","protobuf","test"],"created_at":"2024-10-03T09:55:07.949Z","updated_at":"2025-03-29T16:27:55.997Z","avatar_url":"https://github.com/nbaztec.png","language":"Go","readme":"# protocmp\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) \n[![Coverage Status](https://coveralls.io/repos/github/nbaztec/protocmp/badge.svg?branch=main)](https://coveralls.io/github/nbaztec/protocmp?branch=main)\n\nCompare protobuf v1 and v2 messages with proper error diffs. \n\nThe package is based on the google protobuf package and its respective contents.\n\n### Methods\n* `AssertEqual(t *testing.T, expected proto.Message, actual proto.Message)`\n* `Equal(t *testing.T, expected proto.Message, actual proto.Message) error`\n\n```go\npackage foo\n\nimport \"github.com/nbaztec/protocmp\"\n\n// using AssertEqual\nfunc TestFooBar(t *testing.T) {\n    protocmp.AssertEqual(t, expected, actual)\n}\n\n// using Equal\nfunc TestFooBar(t *testing.T) {\n    if err := protocmp.Equal(expected, actual); err != nil {\n        t.Errorf(\"failed proto: %s\", err)\n    }\n}\n```\n\n### Example\n```go\nfunc TestFoo(t *testing.T) {\n    expected := \u0026sample.Outer{\n    \t\tStrVal:    \"foo\",\n    \t\tIntVal:    1,\n    \t\tBoolVal:   true,\n    \t\tDoubleVal: 1.1,\n    \t\tBytesVal:  []byte{0x01, 0x02},\n    \t\tRepeatedType: []*sample.Outer_Inner{\n    \t\t\t{Id: \"1\"},\n    \t\t\t{Id: \"2\"},\n    \t\t\tnil,\n    \t\t},\n    \t\tMapType: map[string]*sample.Outer_Inner{\n    \t\t\t\"A\": {Id: \"AA\"},\n    \t\t\t\"B\": {Id: \"BB\"},\n    \t\t\t\"C\": nil,\n    \t\t},\n    \t\tEnumType:            sample.Outer_NOT_OK,\n    \t\tOneofType:           \u0026sample.Outer_OneofInt{OneofInt: 1},\n    \t\tLastUpdated:         now,\n    \t\tLastUpdatedDuration: ptypes.DurationProto(1 * time.Second),\n    \t\tDetails: \u0026any.Any{\n    \t\t\tTypeUrl: \"mytype/v1\",\n    \t\t\tValue:   []byte{0x05},\n    \t\t},\n    \t\tRepeatedTypeSimple: []int32{9, 10, 11},\n    \t}\n    \tactual := \u0026sample.Outer{\n    \t\tStrVal:    \"foo\",\n    \t\tIntVal:    10,\n    \t\tBoolVal:   true,\n    \t\tDoubleVal: 1.1,\n    \t\tBytesVal:  []byte{0x01, 0x02},\n    \t\tRepeatedType: []*sample.Outer_Inner{\n    \t\t\t{Id: \"1\"},\n    \t\t\t{Id: \"3\"},\n    \t\t\tnil,\n    \t\t},\n    \t\tMapType: map[string]*sample.Outer_Inner{\n    \t\t\t\"A\": {Id: \"AA\"},\n    \t\t\t\"B\": {Id: \"BB\"},\n    \t\t\t\"C\": nil,\n    \t\t},\n    \t\tEnumType:            sample.Outer_NOT_OK,\n    \t\tOneofType:           \u0026sample.Outer_OneofInt{OneofInt: 1},\n    \t\tLastUpdated:         now,\n    \t\tLastUpdatedDuration: ptypes.DurationProto(1 * time.Second),\n    \t\tDetails: \u0026any.Any{\n    \t\t\tTypeUrl: \"mytype/v1\",\n    \t\t\tValue:   []byte{0x05},\n    \t\t},\n    \t\tRepeatedTypeSimple: []int32{9, 10, 11},\n    \t}\n    \n    \tcmp.AssertEqual(t, a, b)\n}\n```\n```\n/=== RUN   TestCmpAssertEqual\n     TestCmpAssertEqual: main_test.go:18\n        int_val: value mismatch\n            + 1\n            - 10\n --- FAIL: TestCmpAssertEqual (0.00s)\n FAIL\n```","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnbaztec%2Fprotocmp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnbaztec%2Fprotocmp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnbaztec%2Fprotocmp/lists"}