treewide: satisfy go vet checks #586

merged
opened by oppi.li targeting master from push-vwuuzxwwsvow
Changed files
+48 -22
appview
+1 -1
appview/db/label.go
···
defs[l.AtUri().String()] = &l
}
-
return &models.LabelApplicationCtx{defs}, nil
+
return &models.LabelApplicationCtx{Defs: defs}, nil
}
+15 -15
appview/pages/funcmap.go
···
"relTimeFmt": humanize.Time,
"shortRelTimeFmt": func(t time.Time) string {
return humanize.CustomRelTime(t, time.Now(), "", "", []humanize.RelTimeMagnitude{
-
{time.Second, "now", time.Second},
-
{2 * time.Second, "1s %s", 1},
-
{time.Minute, "%ds %s", time.Second},
-
{2 * time.Minute, "1min %s", 1},
-
{time.Hour, "%dmin %s", time.Minute},
-
{2 * time.Hour, "1hr %s", 1},
-
{humanize.Day, "%dhrs %s", time.Hour},
-
{2 * humanize.Day, "1d %s", 1},
-
{20 * humanize.Day, "%dd %s", humanize.Day},
-
{8 * humanize.Week, "%dw %s", humanize.Week},
-
{humanize.Year, "%dmo %s", humanize.Month},
-
{18 * humanize.Month, "1y %s", 1},
-
{2 * humanize.Year, "2y %s", 1},
-
{humanize.LongTime, "%dy %s", humanize.Year},
-
{math.MaxInt64, "a long while %s", 1},
+
{D: time.Second, Format: "now", DivBy: time.Second},
+
{D: 2 * time.Second, Format: "1s %s", DivBy: 1},
+
{D: time.Minute, Format: "%ds %s", DivBy: time.Second},
+
{D: 2 * time.Minute, Format: "1min %s", DivBy: 1},
+
{D: time.Hour, Format: "%dmin %s", DivBy: time.Minute},
+
{D: 2 * time.Hour, Format: "1hr %s", DivBy: 1},
+
{D: humanize.Day, Format: "%dhrs %s", DivBy: time.Hour},
+
{D: 2 * humanize.Day, Format: "1d %s", DivBy: 1},
+
{D: 20 * humanize.Day, Format: "%dd %s", DivBy: humanize.Day},
+
{D: 8 * humanize.Week, Format: "%dw %s", DivBy: humanize.Week},
+
{D: humanize.Year, Format: "%dmo %s", DivBy: humanize.Month},
+
{D: 18 * humanize.Month, Format: "1y %s", DivBy: 1},
+
{D: 2 * humanize.Year, Format: "2y %s", DivBy: 1},
+
{D: humanize.LongTime, Format: "%dy %s", DivBy: humanize.Year},
+
{D: math.MaxInt64, Format: "a long while %s", DivBy: 1},
})
},
"longTimeFmt": func(t time.Time) string {
+30
appview/pages/funcmap_test.go
···
+
package pages
+
+
import (
+
"html/template"
+
"tangled.org/core/appview/config"
+
"tangled.org/core/idresolver"
+
"testing"
+
)
+
+
func TestPages_funcMap(t *testing.T) {
+
tests := []struct {
+
name string // description of this test case
+
// Named input parameters for receiver constructor.
+
config *config.Config
+
res *idresolver.Resolver
+
want template.FuncMap
+
}{
+
// TODO: Add test cases.
+
}
+
for _, tt := range tests {
+
t.Run(tt.name, func(t *testing.T) {
+
p := NewPages(tt.config, tt.res)
+
got := p.funcMap()
+
// TODO: update the condition below to compare got with tt.want.
+
if true {
+
t.Errorf("funcMap() = %v, want %v", got, tt.want)
+
}
+
})
+
}
+
}
-4
appview/pages/pages.go
···
return p
}
-
func (p *Pages) pathToName(s string) string {
-
return strings.TrimSuffix(strings.TrimPrefix(s, "templates/"), ".html")
-
}
-
// reverse of pathToName
func (p *Pages) nameToPath(s string) string {
return "templates/" + s + ".html"
+1 -1
appview/reporesolver/resolver.go
···
func (f *ResolvedRepo) RolesInRepo(u *oauth.User) repoinfo.RolesInRepo {
if u != nil {
r := f.rr.enforcer.GetPermissionsInRepo(u.Did, f.Knot, f.DidSlashRepo())
-
return repoinfo.RolesInRepo{r}
+
return repoinfo.RolesInRepo{Roles: r}
} else {
return repoinfo.RolesInRepo{}
}
+1 -1
appview/state/state.go
···
repoResolver := reporesolver.New(config, enforcer, res, d)
-
wrapper := db.DbWrapper{d}
+
wrapper := db.DbWrapper{Execer: d}
jc, err := jetstream.NewJetstreamClient(
config.Jetstream.Endpoint,
"appview",