2024-01-03 13:36:23 +00:00
|
|
|
package encoding
|
2024-01-03 12:18:19 +00:00
|
|
|
|
|
|
|
import (
|
2024-01-04 07:51:05 +00:00
|
|
|
"git.lumeweb.com/LumeWeb/libs5-go/encoding/testdata"
|
2024-01-03 12:18:19 +00:00
|
|
|
"git.lumeweb.com/LumeWeb/libs5-go/types"
|
|
|
|
"reflect"
|
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestCID_CopyWith(t *testing.T) {
|
|
|
|
type fields struct {
|
2024-01-03 13:36:23 +00:00
|
|
|
Multibase Multibase
|
2024-01-03 12:18:19 +00:00
|
|
|
Type types.CIDType
|
2024-01-03 13:36:23 +00:00
|
|
|
Hash Multihash
|
2024-01-03 12:18:19 +00:00
|
|
|
Size uint32
|
|
|
|
}
|
|
|
|
type args struct {
|
|
|
|
newType int
|
|
|
|
newSize uint32
|
|
|
|
}
|
|
|
|
tests := []struct {
|
|
|
|
name string
|
|
|
|
fields fields
|
|
|
|
args args
|
|
|
|
want *CID
|
|
|
|
wantErr bool
|
|
|
|
}{
|
|
|
|
// TODO: Add test cases.
|
|
|
|
}
|
|
|
|
for _, tt := range tests {
|
|
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
|
|
cid := &CID{
|
|
|
|
Multibase: tt.fields.Multibase,
|
|
|
|
Type: tt.fields.Type,
|
|
|
|
Hash: tt.fields.Hash,
|
|
|
|
Size: tt.fields.Size,
|
|
|
|
}
|
|
|
|
got, err := cid.CopyWith(tt.args.newType, tt.args.newSize)
|
|
|
|
if (err != nil) != tt.wantErr {
|
|
|
|
t.Errorf("CopyWith() error = %v, wantErr %v", err, tt.wantErr)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
if !reflect.DeepEqual(got, tt.want) {
|
|
|
|
t.Errorf("CopyWith() got = %v, want %v", got, tt.want)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestCID_Equals(t *testing.T) {
|
|
|
|
type fields struct {
|
2024-01-03 13:36:23 +00:00
|
|
|
Multibase Multibase
|
2024-01-03 12:18:19 +00:00
|
|
|
Type types.CIDType
|
2024-01-03 13:36:23 +00:00
|
|
|
Hash Multihash
|
2024-01-03 12:18:19 +00:00
|
|
|
Size uint32
|
|
|
|
}
|
|
|
|
type args struct {
|
|
|
|
other *CID
|
|
|
|
}
|
|
|
|
tests := []struct {
|
|
|
|
name string
|
|
|
|
fields fields
|
|
|
|
args args
|
|
|
|
want bool
|
|
|
|
}{
|
|
|
|
// TODO: Add test cases.
|
|
|
|
}
|
|
|
|
for _, tt := range tests {
|
|
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
|
|
cid := &CID{
|
|
|
|
Multibase: tt.fields.Multibase,
|
|
|
|
Type: tt.fields.Type,
|
|
|
|
Hash: tt.fields.Hash,
|
|
|
|
Size: tt.fields.Size,
|
|
|
|
}
|
|
|
|
if got := cid.Equals(tt.args.other); got != tt.want {
|
|
|
|
t.Errorf("Equals() = %v, want %v", got, tt.want)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestCID_HashCode(t *testing.T) {
|
|
|
|
type fields struct {
|
2024-01-03 13:36:23 +00:00
|
|
|
Multibase Multibase
|
2024-01-03 12:18:19 +00:00
|
|
|
Type types.CIDType
|
2024-01-03 13:36:23 +00:00
|
|
|
Hash Multihash
|
2024-01-03 12:18:19 +00:00
|
|
|
Size uint32
|
|
|
|
}
|
|
|
|
tests := []struct {
|
|
|
|
name string
|
|
|
|
fields fields
|
|
|
|
want int
|
|
|
|
}{
|
|
|
|
// TODO: Add test cases.
|
|
|
|
}
|
|
|
|
for _, tt := range tests {
|
|
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
|
|
cid := &CID{
|
|
|
|
Multibase: tt.fields.Multibase,
|
|
|
|
Type: tt.fields.Type,
|
|
|
|
Hash: tt.fields.Hash,
|
|
|
|
Size: tt.fields.Size,
|
|
|
|
}
|
|
|
|
if got := cid.HashCode(); got != tt.want {
|
|
|
|
t.Errorf("HashCode() = %v, want %v", got, tt.want)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*func TestCID_ToBytes(t *testing.T) {
|
2024-01-03 13:36:23 +00:00
|
|
|
CIDFromHash(testdata.RawBase58CID)
|
2024-01-03 12:18:19 +00:00
|
|
|
|
|
|
|
println(len(testdata.RawCIDBytes))
|
|
|
|
println(utils.DecodeEndian(testdata.RawCIDBytes[35:]))
|
|
|
|
return
|
|
|
|
type fields struct {
|
2024-01-07 08:13:35 +00:00
|
|
|
kind types.CIDType
|
2024-01-03 13:36:23 +00:00
|
|
|
Hash Multihash
|
2024-01-03 12:18:19 +00:00
|
|
|
Size uint32
|
|
|
|
}
|
|
|
|
tests := []struct {
|
|
|
|
name string
|
|
|
|
fields fields
|
|
|
|
want []byte
|
|
|
|
}{
|
|
|
|
{
|
|
|
|
name: "Bridge CID",
|
|
|
|
fields: fields{
|
2024-01-07 08:13:35 +00:00
|
|
|
kind: types.CIDTypeBridge,
|
2024-01-03 13:36:23 +00:00
|
|
|
Hash: NewMultibase(), // Replace with a valid hash value
|
2024-01-03 12:18:19 +00:00
|
|
|
},
|
|
|
|
want: , // Replace with the expected byte output for Bridge CID
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "Raw CID with Non-Zero Size",
|
|
|
|
fields: fields{
|
2024-01-07 08:13:35 +00:00
|
|
|
kind: types.CIDTypeRaw,
|
2024-01-03 13:36:23 +00:00
|
|
|
Hash: *NewMultibase(testdata.RawCIDBytes[1:34]),
|
2024-01-03 12:18:19 +00:00
|
|
|
Size: utils.DecodeEndian(testdata.RawCIDBytes[34:]),
|
|
|
|
},
|
|
|
|
want: testdata.RawCIDBytes,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "Raw CID with Zero Size",
|
|
|
|
fields: fields{
|
2024-01-07 08:13:35 +00:00
|
|
|
kind: types.CIDTypeRaw,
|
2024-01-03 12:18:19 +00:00
|
|
|
Hash: yourHashValue, // Replace with a valid hash value
|
|
|
|
Size: 0, // Zero size
|
|
|
|
},
|
|
|
|
want: yourExpectedBytesForRawCIDWithZeroSize, // Replace with the expected byte output
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "Default CID",
|
|
|
|
fields: fields{
|
2024-01-07 08:13:35 +00:00
|
|
|
kind: types.CIDTypeDefault,
|
2024-01-03 12:18:19 +00:00
|
|
|
Hash: yourHashValue, // Replace with a valid hash value
|
|
|
|
},
|
|
|
|
want: yourExpectedBytesForDefaultCID, // Replace with the expected byte output for Default CID
|
|
|
|
},
|
|
|
|
}
|
|
|
|
for _, tt := range tests {
|
|
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
|
|
cid := &CID{
|
2024-01-07 08:13:35 +00:00
|
|
|
kind: tt.fields.kind,
|
2024-01-03 12:18:19 +00:00
|
|
|
Hash: tt.fields.Hash,
|
|
|
|
Size: tt.fields.Size,
|
|
|
|
}
|
2024-01-03 13:36:23 +00:00
|
|
|
m := NewMultibase(cid)
|
2024-01-03 12:18:19 +00:00
|
|
|
cid.Multibase = m
|
|
|
|
if got := cid.ToBytes(); !reflect.DeepEqual(got, tt.want) {
|
|
|
|
t.Errorf("ToBytes() = %v, want %v", got, tt.want)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}*/
|
|
|
|
|
|
|
|
func TestCID_ToRegistryCID(t *testing.T) {
|
|
|
|
type fields struct {
|
2024-01-03 13:36:23 +00:00
|
|
|
Multibase Multibase
|
2024-01-03 12:18:19 +00:00
|
|
|
Type types.CIDType
|
2024-01-03 13:36:23 +00:00
|
|
|
Hash Multihash
|
2024-01-03 12:18:19 +00:00
|
|
|
Size uint32
|
|
|
|
}
|
|
|
|
tests := []struct {
|
|
|
|
name string
|
|
|
|
fields fields
|
|
|
|
want []byte
|
|
|
|
wantErr bool
|
|
|
|
}{
|
|
|
|
// TODO: Add test cases.
|
|
|
|
}
|
|
|
|
for _, tt := range tests {
|
|
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
|
|
cid := &CID{
|
|
|
|
Multibase: tt.fields.Multibase,
|
|
|
|
Type: tt.fields.Type,
|
|
|
|
Hash: tt.fields.Hash,
|
|
|
|
Size: tt.fields.Size,
|
|
|
|
}
|
|
|
|
got, err := cid.ToRegistryCID()
|
|
|
|
if (err != nil) != tt.wantErr {
|
|
|
|
t.Errorf("ToRegistryCID() error = %v, wantErr %v", err, tt.wantErr)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
if !reflect.DeepEqual(got, tt.want) {
|
|
|
|
t.Errorf("ToRegistryCID() got = %v, want %v", got, tt.want)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestCID_ToRegistryEntry(t *testing.T) {
|
|
|
|
type fields struct {
|
2024-01-03 13:36:23 +00:00
|
|
|
Multibase Multibase
|
2024-01-03 12:18:19 +00:00
|
|
|
Type types.CIDType
|
2024-01-03 13:36:23 +00:00
|
|
|
Hash Multihash
|
2024-01-03 12:18:19 +00:00
|
|
|
Size uint32
|
|
|
|
}
|
|
|
|
tests := []struct {
|
|
|
|
name string
|
|
|
|
fields fields
|
|
|
|
want []byte
|
|
|
|
}{
|
|
|
|
// TODO: Add test cases.
|
|
|
|
}
|
|
|
|
for _, tt := range tests {
|
|
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
|
|
cid := &CID{
|
|
|
|
Multibase: tt.fields.Multibase,
|
|
|
|
Type: tt.fields.Type,
|
|
|
|
Hash: tt.fields.Hash,
|
|
|
|
Size: tt.fields.Size,
|
|
|
|
}
|
|
|
|
if got := cid.ToRegistryEntry(); !reflect.DeepEqual(got, tt.want) {
|
|
|
|
t.Errorf("ToRegistryEntry() = %v, want %v", got, tt.want)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestCID_ToString(t *testing.T) {
|
|
|
|
type fields struct {
|
2024-01-03 13:36:23 +00:00
|
|
|
Multibase Multibase
|
2024-01-03 12:18:19 +00:00
|
|
|
Type types.CIDType
|
2024-01-03 13:36:23 +00:00
|
|
|
Hash Multihash
|
2024-01-03 12:18:19 +00:00
|
|
|
Size uint32
|
|
|
|
}
|
|
|
|
tests := []struct {
|
|
|
|
name string
|
|
|
|
fields fields
|
|
|
|
want string
|
|
|
|
wantErr bool
|
|
|
|
}{
|
|
|
|
// TODO: Add test cases.
|
|
|
|
}
|
|
|
|
for _, tt := range tests {
|
|
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
|
|
cid := &CID{
|
|
|
|
Multibase: tt.fields.Multibase,
|
|
|
|
Type: tt.fields.Type,
|
|
|
|
Hash: tt.fields.Hash,
|
|
|
|
Size: tt.fields.Size,
|
|
|
|
}
|
|
|
|
got, err := cid.ToString()
|
|
|
|
if (err != nil) != tt.wantErr {
|
|
|
|
t.Errorf("ToString() error = %v, wantErr %v", err, tt.wantErr)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
if got != tt.want {
|
|
|
|
t.Errorf("ToString() got = %v, want %v", got, tt.want)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestCID_getPrefixBytes(t *testing.T) {
|
|
|
|
type fields struct {
|
2024-01-03 13:36:23 +00:00
|
|
|
Multibase Multibase
|
2024-01-03 12:18:19 +00:00
|
|
|
Type types.CIDType
|
2024-01-03 13:36:23 +00:00
|
|
|
Hash Multihash
|
2024-01-03 12:18:19 +00:00
|
|
|
Size uint32
|
|
|
|
}
|
|
|
|
tests := []struct {
|
|
|
|
name string
|
|
|
|
fields fields
|
|
|
|
want []byte
|
|
|
|
}{
|
|
|
|
// TODO: Add test cases.
|
|
|
|
}
|
|
|
|
for _, tt := range tests {
|
|
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
|
|
cid := &CID{
|
|
|
|
Multibase: tt.fields.Multibase,
|
|
|
|
Type: tt.fields.Type,
|
|
|
|
Hash: tt.fields.Hash,
|
|
|
|
Size: tt.fields.Size,
|
|
|
|
}
|
|
|
|
if got := cid.getPrefixBytes(); !reflect.DeepEqual(got, tt.want) {
|
|
|
|
t.Errorf("getPrefixBytes() = %v, want %v", got, tt.want)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestDecode(t *testing.T) {
|
|
|
|
type args struct {
|
|
|
|
cid string
|
|
|
|
}
|
|
|
|
tests := []struct {
|
|
|
|
name string
|
|
|
|
args args
|
|
|
|
want *CID
|
|
|
|
wantErr bool
|
|
|
|
}{
|
|
|
|
/* {
|
|
|
|
name: "Valid Bridge CID",
|
|
|
|
args:args {cid: ""},
|
|
|
|
want: nil,
|
|
|
|
wantErr: false,
|
|
|
|
},*/
|
|
|
|
|
|
|
|
{
|
|
|
|
name: "Valid Raw Base 58 CID",
|
|
|
|
args: args{cid: testdata.RawBase58CID},
|
2024-01-03 13:36:23 +00:00
|
|
|
want: NewCID(types.CIDTypeRaw, *NewMultihash(testdata.RawCIDBytes[1:34]), testdata.RawCIDSize),
|
2024-01-03 12:18:19 +00:00
|
|
|
wantErr: false,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "Valid Media 58 CID",
|
|
|
|
args: args{cid: testdata.MediaBase58CID},
|
2024-01-03 13:36:23 +00:00
|
|
|
want: NewCID(types.CIDTypeMetadataMedia, *NewMultihash(testdata.MediaCIDBytes[1:34]), testdata.MediaCIDSize),
|
2024-01-03 12:18:19 +00:00
|
|
|
wantErr: false,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "Valid Resolver CID",
|
|
|
|
args: args{cid: testdata.ResolverBase58CID},
|
2024-01-03 13:36:23 +00:00
|
|
|
want: NewCID(types.CIDTypeResolver, *NewMultihash(testdata.ResolverCIDBytes[1:34]), testdata.ResolverCIDSize),
|
2024-01-03 12:18:19 +00:00
|
|
|
wantErr: false,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
for _, tt := range tests {
|
|
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
|
|
got, err := Decode(tt.args.cid)
|
|
|
|
if (err != nil) != tt.wantErr {
|
|
|
|
t.Errorf("DecodeCID() error = %v, wantErr %v", err, tt.wantErr)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
if !reflect.DeepEqual(got, tt.want) {
|
|
|
|
t.Errorf("DecodeCID() got = %v, want %v", got, tt.want)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestFromBytes(t *testing.T) {
|
|
|
|
type args struct {
|
|
|
|
bytes []byte
|
|
|
|
}
|
|
|
|
tests := []struct {
|
|
|
|
name string
|
|
|
|
args args
|
|
|
|
want *CID
|
|
|
|
wantErr bool
|
|
|
|
}{
|
|
|
|
{
|
|
|
|
name: "Valid Raw Base 58 CID",
|
|
|
|
args: args{bytes: testdata.RawCIDBytes},
|
2024-01-03 13:36:23 +00:00
|
|
|
want: NewCID(types.CIDTypeRaw, *NewMultihash(testdata.RawCIDBytes[1:34]), testdata.RawCIDSize),
|
2024-01-03 12:18:19 +00:00
|
|
|
wantErr: false,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "Valid Media 58 CID",
|
|
|
|
args: args{bytes: testdata.MediaCIDBytes},
|
2024-01-03 13:36:23 +00:00
|
|
|
want: NewCID(types.CIDTypeMetadataMedia, *NewMultihash(testdata.MediaCIDBytes[1:34]), testdata.MediaCIDSize),
|
2024-01-03 12:18:19 +00:00
|
|
|
wantErr: false,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "Valid Resolver CID",
|
|
|
|
args: args{bytes: testdata.ResolverCIDBytes},
|
2024-01-03 13:36:23 +00:00
|
|
|
want: NewCID(types.CIDTypeResolver, *NewMultihash(testdata.ResolverCIDBytes[1:34]), testdata.ResolverCIDSize),
|
2024-01-03 12:18:19 +00:00
|
|
|
wantErr: false,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
for _, tt := range tests {
|
|
|
|
t.Run(tt.name, func(t *testing.T) {
|
2024-01-03 13:36:23 +00:00
|
|
|
got, err := CIDFromBytes(tt.args.bytes)
|
2024-01-03 12:18:19 +00:00
|
|
|
if (err != nil) != tt.wantErr {
|
2024-01-03 13:36:23 +00:00
|
|
|
t.Errorf("CIDFromBytes() error = %v, wantErr %v", err, tt.wantErr)
|
2024-01-03 12:18:19 +00:00
|
|
|
return
|
|
|
|
}
|
|
|
|
if !reflect.DeepEqual(got, tt.want) {
|
2024-01-03 13:36:23 +00:00
|
|
|
t.Errorf("CIDFromBytes() got = %v, want %v", got, tt.want)
|
2024-01-03 12:18:19 +00:00
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestFromHash(t *testing.T) {
|
|
|
|
type args struct {
|
|
|
|
bytes interface{}
|
|
|
|
size uint32
|
|
|
|
cidType types.CIDType
|
|
|
|
}
|
|
|
|
tests := []struct {
|
|
|
|
name string
|
|
|
|
args args
|
|
|
|
want *CID
|
|
|
|
wantErr bool
|
|
|
|
}{
|
|
|
|
{
|
|
|
|
name: "Valid Raw Base 58 CID",
|
|
|
|
args: args{bytes: testdata.RawCIDBytes[1:34], size: testdata.RawCIDSize, cidType: types.CIDTypeRaw},
|
2024-01-03 13:36:23 +00:00
|
|
|
want: NewCID(types.CIDTypeRaw, *NewMultihash(testdata.RawCIDBytes[1:34]), testdata.RawCIDSize),
|
2024-01-03 12:18:19 +00:00
|
|
|
wantErr: false,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "Valid Media 58 CID",
|
|
|
|
args: args{bytes: testdata.MediaCIDBytes[1:34], size: testdata.MediaCIDSize, cidType: types.CIDTypeMetadataMedia},
|
2024-01-03 13:36:23 +00:00
|
|
|
want: NewCID(types.CIDTypeMetadataMedia, *NewMultihash(testdata.MediaCIDBytes[1:34]), testdata.MediaCIDSize),
|
2024-01-03 12:18:19 +00:00
|
|
|
wantErr: false,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "Valid Resolver CID",
|
|
|
|
args: args{bytes: testdata.ResolverCIDBytes[1:34], size: testdata.ResolverCIDSize, cidType: types.CIDTypeResolver},
|
2024-01-03 13:36:23 +00:00
|
|
|
want: NewCID(types.CIDTypeResolver, *NewMultihash(testdata.ResolverCIDBytes[1:34]), testdata.ResolverCIDSize),
|
2024-01-03 12:18:19 +00:00
|
|
|
wantErr: false,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
for _, tt := range tests {
|
|
|
|
t.Run(tt.name, func(t *testing.T) {
|
2024-01-03 13:36:23 +00:00
|
|
|
got, err := CIDFromHash(tt.args.bytes, tt.args.size, tt.args.cidType)
|
2024-01-03 12:18:19 +00:00
|
|
|
if (err != nil) != tt.wantErr {
|
2024-01-03 13:36:23 +00:00
|
|
|
t.Errorf("CIDFromHash() error = %v, wantErr %v", err, tt.wantErr)
|
2024-01-03 12:18:19 +00:00
|
|
|
return
|
|
|
|
}
|
|
|
|
if !reflect.DeepEqual(got, tt.want) {
|
2024-01-03 13:36:23 +00:00
|
|
|
t.Errorf("CIDFromHash() got = %v, want %v", got, tt.want)
|
2024-01-03 12:18:19 +00:00
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestFromRegistry(t *testing.T) {
|
|
|
|
type args struct {
|
|
|
|
bytes []byte
|
|
|
|
}
|
|
|
|
tests := []struct {
|
|
|
|
name string
|
|
|
|
args args
|
|
|
|
want *CID
|
|
|
|
wantErr bool
|
|
|
|
}{
|
|
|
|
{
|
|
|
|
name: "Valid Resolver Data",
|
|
|
|
args: args{bytes: testdata.ResolverDataBytes},
|
2024-01-03 13:36:23 +00:00
|
|
|
want: NewCID(types.CIDTypeMetadataWebapp, *NewMultihash(testdata.ResolverDataBytes[2:35]), testdata.ResolverDataSize),
|
2024-01-03 12:18:19 +00:00
|
|
|
wantErr: false,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
for _, tt := range tests {
|
|
|
|
t.Run(tt.name, func(t *testing.T) {
|
2024-01-03 13:36:23 +00:00
|
|
|
got, err := CIDFromRegistry(tt.args.bytes)
|
2024-01-03 12:18:19 +00:00
|
|
|
if (err != nil) != tt.wantErr {
|
2024-01-03 13:36:23 +00:00
|
|
|
t.Errorf("CIDFromRegistry() error = %v, wantErr %v", err, tt.wantErr)
|
2024-01-03 12:18:19 +00:00
|
|
|
return
|
|
|
|
}
|
|
|
|
if !reflect.DeepEqual(got, tt.want) {
|
2024-01-03 13:36:23 +00:00
|
|
|
t.Errorf("CIDFromRegistry() got = %v, want %v", got, tt.want)
|
2024-01-03 12:18:19 +00:00
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|