Skip to content

Commit

Permalink
remove func originalPath
Browse files Browse the repository at this point in the history
  • Loading branch information
Songmu committed Nov 3, 2023
1 parent db9be0f commit 9ee2089
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 72 deletions.
7 changes: 0 additions & 7 deletions broker.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,13 +206,6 @@ func (b *broker) RemoveEntry(e *entry, p string) error {
return os.Remove(p)
}

func (b *broker) originalPath(e *entry) string {
if e.URL == nil {
return ""
}
return b.LocalPath(e)
}

func atomEndpointURLRoot(bc *blogConfig) string {
owner := bc.Owner
if owner == "" {
Expand Down
65 changes: 0 additions & 65 deletions broker_test.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
package main

import (
"net/url"
"runtime"
"testing"
"time"
)

func TestEntryEndPointUrl(t *testing.T) {
Expand Down Expand Up @@ -41,65 +38,3 @@ func TestEntryEndPointUrl(t *testing.T) {
})
}
}

func TestOriginalPath(t *testing.T) {
u, _ := url.Parse("http://hatenablog.example.com/2")
jst, _ := time.LoadLocation("Asia/Tokyo")
d := time.Date(2023, 10, 10, 0, 0, 0, 0, jst)

testCases := []struct {
name string
entry entry
expect string
expectWindows string
}{
{
name: "entry has URL",
entry: entry{
entryHeader: &entryHeader{
URL: &entryURL{u},
EditURL: u.String() + "/edit",
Title: "test",
Date: &d,
IsDraft: true,
},
LastModified: &d,
Content: "テスト",
},
expect: "example1.hatenablog.com/2.md",
expectWindows: "example1.hatenablog.com\\2.md",
},
{
name: "Not URL",
entry: entry{
entryHeader: &entryHeader{
EditURL: u.String() + "/edit",
Title: "hoge",
IsDraft: true,
},
LastModified: &d,
Content: "テスト",
},
expect: "",
expectWindows: "",
},
}

config := blogConfig{
BlogID: "example1.hatenablog.com",
Username: "sample1",
}
broker := newBroker(&config, nil)

for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
got := broker.originalPath(&tc.entry)
if runtime.GOOS == "windows" {
tc.expect = tc.expectWindows
}
if tc.expect != got {
t.Errorf("expect: %s, got: %s", tc.expect, got)
}
})
}
}

0 comments on commit 9ee2089

Please sign in to comment.