-
-
Notifications
You must be signed in to change notification settings - Fork 11
/
rts_test.go
55 lines (48 loc) · 1.24 KB
/
rts_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
/*
* RTS: Request to Struct. Generates Go structs from a server response.
* Copyright (C) 2016-2022 Paolo Galeone <[email protected]>
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
* Exhibit B is not attached; this software is compatible with the
* licenses expressed under Section 1.12 of the MPL v2.
*/
package rts_test
import (
"bytes"
"os"
"testing"
"github.com/galeone/rts"
)
var (
server = "https://api.github.com"
lines = []string{
"/",
"/repos/:user/:repo galeone igor",
}
pkg = "example"
headerMap = map[string]string{}
expectedGeneration []byte
insecure = false
subStruct = true
)
func init() {
var e error
expectedGeneration, e = os.ReadFile("expected_out")
if e != nil {
panic(e.Error())
}
}
func TestDo(t *testing.T) {
var file []byte
var e error
file, e = rts.Do(pkg, server, lines, headerMap, insecure, subStruct)
if e != nil {
t.Fatalf("No error expected but got: %s", e.Error())
}
if !bytes.Equal(file, expectedGeneration) {
t.Errorf("Results should be equal, but they differs")
t.Error(string(file))
}
}