Skip to content

Commit

Permalink
tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
boyter committed Aug 2, 2023
1 parent 4c49d9e commit 77152ef
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 44 deletions.
24 changes: 5 additions & 19 deletions cmd/badges/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,28 +41,14 @@ func processPath(path string) (location, error) {
return location{}, errors.New("")
}

return location{}, nil
return location{
Location: s[0],
User: s[1],
Repo: s[2],
}, nil
}

func formatCount(count float64) string {
//ranges = [
// (1e18, 'E'),
// (1e15, 'P'),
// (1e12, 'T'),
// (1e9, 'G'),
// (1e6, 'M'),
// (1e3, 'k'),
//]
//
//for x, y in ranges:
// if count >= x:
// t = str(round(count / x, 1))
// if len(t) > 3:
// t = t[:t.find('.')]
// return t + y
//
//return str(round(count, 1))

type r struct {
val float64
sym string
Expand Down
75 changes: 50 additions & 25 deletions cmd/badges/main_test.go
Original file line number Diff line number Diff line change
@@ -1,34 +1,10 @@
package main

import (
"reflect"
"testing"
)

func Test_processPath(t *testing.T) {
type args struct {
path string
}
tests := []struct {
name string
args args
}{
{
name: "",
args: args{
path: "/github/boyter/really-cheap-chatbot/",
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
_, err := processPath(tt.args.path)
if err != nil {
t.Error("err")
}
})
}
}

func Test_formatCount(t *testing.T) {
type args struct {
count float64
Expand Down Expand Up @@ -96,3 +72,52 @@ func Test_formatCount(t *testing.T) {
})
}
}

func Test_processPath(t *testing.T) {
type args struct {
path string
}
tests := []struct {
name string
args args
want location
wantErr bool
}{
{
name: "",
args: args{
path: "/github/boyter/really-cheap-chatbot/",
},
want: location{
Location: "github",
User: "boyter",
Repo: "really-cheap-chatbot",
},
wantErr: false,
},
{
name: "",
args: args{
path: "github/boyter/really-cheap-chatbot",
},
want: location{
Location: "github",
User: "boyter",
Repo: "really-cheap-chatbot",
},
wantErr: false,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got, err := processPath(tt.args.path)
if (err != nil) != tt.wantErr {
t.Errorf("processPath() error = %v, wantErr %v", err, tt.wantErr)
return
}
if !reflect.DeepEqual(got, tt.want) {
t.Errorf("processPath() got = %v, want %v", got, tt.want)
}
})
}
}

0 comments on commit 77152ef

Please sign in to comment.