-
Notifications
You must be signed in to change notification settings - Fork 1
/
publishRaw_test.go
84 lines (79 loc) · 1.91 KB
/
publishRaw_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
package main
import (
"github.com/nbd-wtf/go-nostr"
"testing"
)
/* コピれ {{{
func TestFunc(t *testing.T) {
list := NewSubCmdKindTbl()
tests := []struct{
commandLine []string
err error
}{
{
commandLine: []string{"nostk","pubMessage","テストコンテント"},
err: nil,
},
{
commandLine: []string{"nostk","pubMessage","テストコンテント","nsfwの理由"},
err: nil,
},
{
commandLine: []string{"nostk","pubMessageTo","テストコンテント","npub1czyqt7dafpysfye9w3agpp4rcrsxnt0tr8v0t8kyu66327maxstq5ckh7u"},
err: nil,
},
{
commandLine: []string{"nostk","pubMessageTo","テストコンテント","c08805f9bd4849049325747a8086a3c0e069adeb19d8f59ec4e6b5157b7d3416"},
err: nil,
},
{
commandLine: []string{"nostk","pubRaw","テストコンテント","c08805f9bd4849049325747a8086a3c0e069adeb19d8f59ec4e6b5157b7d3416"},
err: errors.New("Not supported subcommand pubRaw"),
},
}
for _, tc := range tests {
strJson, err := buildJson(tests[i].commandLine)
if err != nil {
t.Fatalf("commandLine : %v, got error: %v, Want error: nil",tests[i].commandLine, err)
} else {
t.Logf("recieve json %v",strJson)
}
}
}
}}} */
func TestReplaceBech32(t *testing.T) {
tests := []struct {
Kind int
Tgs nostr.Tags
Err error
}{
{
Kind: 1,
Tgs: nostr.Tags{
{"p", "npub1czyqt7dafpysfye9w3agpp4rcrsxnt0tr8v0t8kyu66327maxstq5ckh7u"},
},
Err: nil,
},
{
Kind: 1,
Tgs: nostr.Tags{
{"p", "c08805f9bd4849049325747a8086a3c0e069adeb19d8f59ec4e6b5157b7d3416"},
},
Err: nil,
},
{
Kind: 1,
Tgs: nostr.Tags{
{"p", "nsec149qult2em55mwvm07m3fyvu0hdkfyc8c5s3dqetsu0jcn2psavwqvyvxwu"},
},
Err: nil,
},
}
for _, tc := range tests {
err := replaceBech32(tc.Kind, tc.Tgs)
if err != tc.Err {
t.Logf("test kind: %v, test tags: %v", tc.Kind, tc.Tgs)
t.Fatalf("got error: %v, Want error: %v", err, tc.Err)
}
}
}