-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1a98936
commit a38397a
Showing
2 changed files
with
63 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// SPDX-FileCopyrightText: 2023 PK Lab AG <[email protected]> | ||
// SPDX-License-Identifier: MIT | ||
|
||
package responses | ||
|
||
import ( | ||
"encoding/hex" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func Test_decodeName(t *testing.T) { | ||
tests := []struct { | ||
name string | ||
nsId string | ||
want string | ||
}{ | ||
{ | ||
name: "test 1", | ||
nsId: "6d656d6573", | ||
want: "memes", | ||
}, { | ||
name: "test 2", | ||
nsId: "0000000000000000000000000000006d656d6573", | ||
want: "memes", | ||
}, { | ||
name: "test 3", | ||
nsId: "0000000000000000000000000000000000000000e6edd3ffbef8c7d8", | ||
want: "e6edd3ffbef8c7d8", | ||
}, | ||
} | ||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
decoded, err := hex.DecodeString(tt.nsId) | ||
require.NoError(t, err) | ||
|
||
got := decodeName(decoded) | ||
require.Equal(t, tt.want, got) | ||
}) | ||
} | ||
} |