Within package layout (#102)

* blog: go package layout

* eat my own dogfood

* internal: test date

* blog/go-package-layout: streamline

* oops
This commit is contained in:
Cadey Ratio 2019-12-09 10:48:40 -05:00 committed by GitHub
parent 583cf248b3
commit eb26857c1d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
19 changed files with 41 additions and 13 deletions

View File

@ -9,8 +9,8 @@ import (
"strings" "strings"
"time" "time"
"christine.website/internal" "christine.website/cmd/site/internal"
"christine.website/internal/blog" "christine.website/cmd/site/internal/blog"
"github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promauto" "github.com/prometheus/client_golang/prometheus/promauto"
"within.website/ln" "within.website/ln"

View File

@ -9,7 +9,7 @@ import (
"strings" "strings"
"time" "time"
"christine.website/internal/front" "christine.website/cmd/site/internal/front"
"github.com/russross/blackfriday" "github.com/russross/blackfriday"
) )

View File

@ -5,7 +5,7 @@ import (
) )
func TestLoadPosts(t *testing.T) { func TestLoadPosts(t *testing.T) {
posts, err := LoadPosts("../../blog", "blog") posts, err := LoadPosts("../../../../blog", "blog")
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
@ -16,7 +16,7 @@ func TestLoadPosts(t *testing.T) {
} }
func TestLoadTalks(t *testing.T) { func TestLoadTalks(t *testing.T) {
talks, err := LoadPosts("../../talks", "talks") talks, err := LoadPosts("../../../../talks", "talks")
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
@ -30,7 +30,7 @@ func TestLoadTalks(t *testing.T) {
} }
func TestLoadGallery(t *testing.T) { func TestLoadGallery(t *testing.T) {
gallery, err := LoadPosts("../../gallery", "gallery") gallery, err := LoadPosts("../../../../gallery", "gallery")
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }

View File

@ -2,7 +2,7 @@ package internal
import "time" import "time"
const iOS13DetriFormat = `2006 M01 2` const iOS13DetriFormat = `2006 M1 2`
// IOS13Detri formats a datestamp like iOS 13 does with the Lojban locale. // IOS13Detri formats a datestamp like iOS 13 does with the Lojban locale.
func IOS13Detri(t time.Time) string { func IOS13Detri(t time.Time) string {

View File

@ -0,0 +1,28 @@
package internal
import (
"fmt"
"testing"
"time"
)
func TestIOS13Detri(t *testing.T) {
cases := []struct {
in time.Time
out string
}{
{
in: time.Date(2019, time.March, 30, 0, 0, 0, 0, time.FixedZone("UTC", 0)),
out: "2019 M3 30",
},
}
for _, cs := range cases {
t.Run(fmt.Sprintf("%s -> %s", cs.in.Format(time.RFC3339), cs.out), func(t *testing.T) {
result := IOS13Detri(cs.in)
if result != cs.out {
t.Fatalf("wanted: %s, got: %s", cs.out, result)
}
})
}
}

View File

@ -4,7 +4,7 @@ import (
"fmt" "fmt"
"log" "log"
"christine.website/internal/front" "christine.website/cmd/site/internal/front"
) )
var markdown = []byte(`--- var markdown = []byte(`---

View File

@ -9,7 +9,7 @@ import (
"testing" "testing"
"time" "time"
"christine.website/internal/jsonfeed" "christine.website/cmd/site/internal/jsonfeed"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
) )

View File

@ -9,9 +9,9 @@ import (
"sort" "sort"
"time" "time"
"christine.website/internal/blog" "christine.website/cmd/site/internal/blog"
"christine.website/internal/jsonfeed" "christine.website/cmd/site/internal/jsonfeed"
"christine.website/internal/middleware" "christine.website/cmd/site/internal/middleware"
"github.com/gorilla/feeds" "github.com/gorilla/feeds"
"github.com/povilasv/prommod" "github.com/povilasv/prommod"
"github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus"

View File

@ -5,7 +5,7 @@ import (
"net/http" "net/http"
"time" "time"
"christine.website/internal" "christine.website/cmd/site/internal"
"within.website/ln" "within.website/ln"
"within.website/ln/opname" "within.website/ln/opname"
) )