This repository has been archived by the owner on Apr 21, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tests.go
83 lines (68 loc) · 1.57 KB
/
tests.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
package main
import (
"database/sql"
"fmt"
"os"
"github.com/bwmarrin/discordgo"
)
func testInsertWelcomeChannel(s *discordgo.Session) {
// Get guild
guild, err := s.Guild("365011717375262720")
if err != nil {
fmt.Println("Couldn't get a guild.")
fmt.Println(err.Error())
return
}
// Get channel
channel, err := s.Channel("365011718025248769")
if err != nil {
fmt.Println("Couldn't get a channel.")
fmt.Println(err.Error())
return
}
// Insert Welcome Channel
res, err := insertWelcomeChannel(guild, channel)
if err != nil {
fmt.Println("Couldn't insert a welcome channel.")
fmt.Println(err.Error())
return
}
// Get last insert ID
liid, err := res.LastInsertId()
if err != nil {
fmt.Println("Couldn't get the last insert ID.")
fmt.Println(err.Error())
return
}
fmt.Println("LastInsertId :", liid)
// Get rows affected
ra, err := res.RowsAffected()
if err != nil {
fmt.Println("Couldn't get the rows affected.")
fmt.Println(err.Error())
return
}
fmt.Println("RowsAffected :", ra)
os.Exit(0)
}
func testSelectNothing(s *discordgo.Session) {
// Get guild
guild, err := s.Guild("365011717375262720")
if err != nil {
fmt.Println("Couldn't get a guild.")
fmt.Println(err.Error())
return
}
// Select a presentation channel
pc, err := selectPresentationChannel(guild)
if err != nil {
fmt.Println("Couldn't select this presentation channel.")
fmt.Println(err.Error())
if err == sql.ErrNoRows {
fmt.Println("The error is", "sql: no rows in result set")
}
return
}
fmt.Println("Presentation Channel :", pc)
os.Exit(0)
}