Skip to content

Commit 77152ef

Browse files
committed
tweaks
1 parent 4c49d9e commit 77152ef

File tree

2 files changed

+55
-44
lines changed

2 files changed

+55
-44
lines changed

cmd/badges/main.go

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -41,28 +41,14 @@ func processPath(path string) (location, error) {
4141
return location{}, errors.New("")
4242
}
4343

44-
return location{}, nil
44+
return location{
45+
Location: s[0],
46+
User: s[1],
47+
Repo: s[2],
48+
}, nil
4549
}
4650

4751
func formatCount(count float64) string {
48-
//ranges = [
49-
// (1e18, 'E'),
50-
// (1e15, 'P'),
51-
// (1e12, 'T'),
52-
// (1e9, 'G'),
53-
// (1e6, 'M'),
54-
// (1e3, 'k'),
55-
//]
56-
//
57-
//for x, y in ranges:
58-
// if count >= x:
59-
// t = str(round(count / x, 1))
60-
// if len(t) > 3:
61-
// t = t[:t.find('.')]
62-
// return t + y
63-
//
64-
//return str(round(count, 1))
65-
6652
type r struct {
6753
val float64
6854
sym string

cmd/badges/main_test.go

Lines changed: 50 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,10 @@
11
package main
22

33
import (
4+
"reflect"
45
"testing"
56
)
67

7-
func Test_processPath(t *testing.T) {
8-
type args struct {
9-
path string
10-
}
11-
tests := []struct {
12-
name string
13-
args args
14-
}{
15-
{
16-
name: "",
17-
args: args{
18-
path: "/github/boyter/really-cheap-chatbot/",
19-
},
20-
},
21-
}
22-
for _, tt := range tests {
23-
t.Run(tt.name, func(t *testing.T) {
24-
_, err := processPath(tt.args.path)
25-
if err != nil {
26-
t.Error("err")
27-
}
28-
})
29-
}
30-
}
31-
328
func Test_formatCount(t *testing.T) {
339
type args struct {
3410
count float64
@@ -96,3 +72,52 @@ func Test_formatCount(t *testing.T) {
9672
})
9773
}
9874
}
75+
76+
func Test_processPath(t *testing.T) {
77+
type args struct {
78+
path string
79+
}
80+
tests := []struct {
81+
name string
82+
args args
83+
want location
84+
wantErr bool
85+
}{
86+
{
87+
name: "",
88+
args: args{
89+
path: "/github/boyter/really-cheap-chatbot/",
90+
},
91+
want: location{
92+
Location: "github",
93+
User: "boyter",
94+
Repo: "really-cheap-chatbot",
95+
},
96+
wantErr: false,
97+
},
98+
{
99+
name: "",
100+
args: args{
101+
path: "github/boyter/really-cheap-chatbot",
102+
},
103+
want: location{
104+
Location: "github",
105+
User: "boyter",
106+
Repo: "really-cheap-chatbot",
107+
},
108+
wantErr: false,
109+
},
110+
}
111+
for _, tt := range tests {
112+
t.Run(tt.name, func(t *testing.T) {
113+
got, err := processPath(tt.args.path)
114+
if (err != nil) != tt.wantErr {
115+
t.Errorf("processPath() error = %v, wantErr %v", err, tt.wantErr)
116+
return
117+
}
118+
if !reflect.DeepEqual(got, tt.want) {
119+
t.Errorf("processPath() got = %v, want %v", got, tt.want)
120+
}
121+
})
122+
}
123+
}

0 commit comments

Comments
 (0)