Skip to content

Commit

Permalink
Go recognizes testdata directory
Browse files Browse the repository at this point in the history
  • Loading branch information
ohtake committed Nov 15, 2017
1 parent 707bb4b commit 18f28bb
Show file tree
Hide file tree
Showing 10 changed files with 14 additions and 14 deletions.
4 changes: 2 additions & 2 deletions chunk_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func ReadAllChunksAsInfo(chunkSize int, channelDirectory string) []ChunkInfo {
}

func TestChunkedHistoryReader(t *testing.T) {
actual := ReadAllChunks(4, "test_data/channel1")
actual := ReadAllChunks(4, "testdata/channel1")
expectedChunkSizes := []int{4, 2}
if len(expectedChunkSizes) != len(actual) {
t.Errorf("Wrong length: %d, %d", len(expectedChunkSizes), len(actual))
Expand All @@ -49,7 +49,7 @@ func TestChunkedHistoryReader(t *testing.T) {
func TestToChunkInfo(t *testing.T) {
expectedMessageSizes := []int{3, 3}
expectedYear := 2016
actual := ReadAllChunksAsInfo(3, "test_data/channel1")
actual := ReadAllChunksAsInfo(3, "testdata/channel1")

for i := 0; i < len(actual); i++ {
if actual[i].NumMessages != expectedMessageSizes[i] {
Expand Down
12 changes: 6 additions & 6 deletions markdown_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func TestMarkdownHeadings(t *testing.T) {

func TestMarkdownChannelList(t *testing.T) {
m := NewMarkdownTranslator()
channels := ReadChannels("test_data/channels.json")
channels := ReadChannels("testdata/channels.json")
testLines(t, m.ToChannelList(channels), []string{
"* [\\#channel1](channel--channel1.md)",
"* [\\#channel2](channel--channel2.md)",
Expand All @@ -64,7 +64,7 @@ func TestMarkdownChannelList(t *testing.T) {

func TestMarkdownChunkList(t *testing.T) {
m := NewMarkdownTranslator()
chunkInfos := ReadAllChunksAsInfo(3, "test_data/channel1")
chunkInfos := ReadAllChunksAsInfo(3, "testdata/channel1")
actual := m.ToChunkList(chunkInfos)
testLines(t, actual, []string{
"* [1 (2016-05-13T08:43:07Z - 2016-05-13T08:43:09Z)](history--channel1--1.md)",
Expand All @@ -74,10 +74,10 @@ func TestMarkdownChunkList(t *testing.T) {
}

func TestMarkdownMessageList(t *testing.T) {
channels := ReadChannels("test_data/channels.json")
users := ReadUsers("test_data/users.json")
channels := ReadChannels("testdata/channels.json")
users := ReadUsers("testdata/users.json")
resolver := NewResolver(channels, users)
chunks := ReadAllChunks(3, "test_data/channel1")
chunks := ReadAllChunks(3, "testdata/channel1")
resolvedMessages := make([]MessageResolved, 0, len(chunks[0]))
for _, m := range chunks[0] {
resolvedMessages = append(resolvedMessages, resolver.Resolve(&m))
Expand All @@ -93,7 +93,7 @@ func TestMarkdownMessageList(t *testing.T) {
}

func TestMarkdownUserTable(t *testing.T) {
users := ReadUsers("test_data/users.json")
users := ReadUsers("testdata/users.json")
m := NewMarkdownTranslator()
actual := m.ToUserTable(users)
testLines(t, actual, []string{
Expand Down
4 changes: 2 additions & 2 deletions resolver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
)

func newResolver() *Resolver {
return NewResolver(ReadChannels("test_data/channels.json"), ReadUsers("test_data/users.json"))
return NewResolver(ReadChannels("testdata/channels.json"), ReadUsers("testdata/users.json"))
}

func TestResolve(t *testing.T) {
Expand All @@ -33,7 +33,7 @@ func TestResolve(t *testing.T) {

func TestResolveMessage(t *testing.T) {
resolver := newResolver()
messages := ReadHistory("test_data/channel1/2016-05-13.json")
messages := ReadHistory("testdata/channel1/2016-05-13.json")

m1 := resolver.Resolve(&messages[0])
if m1.User.Name != "alice" {
Expand Down
2 changes: 1 addition & 1 deletion scripts/update_example.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

git checkout -B example
go build
./slack2md -input test_data -messages 4
./slack2md -input testdata -messages 4
git add -f output
git commit -m "example"
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
6 changes: 3 additions & 3 deletions unmarshaller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
)

func TestReadChannels(t *testing.T) {
actual := ReadChannels("test_data/channels.json")
actual := ReadChannels("testdata/channels.json")
expected := []Channel{
{"C00000001", "channel1", "1463128988"},
{"C00000002", "channel2", "1436515520"},
Expand All @@ -29,7 +29,7 @@ func TestReadChannels(t *testing.T) {
}

func TestReadUsers(t *testing.T) {
actual := ReadUsers("test_data/users.json")
actual := ReadUsers("testdata/users.json")
expected := []User{
{"U00000001", "alice", UserProfile{"[email protected]", "Alice", "Doe", "Alice Doe", "Alice Doe", "title1", "https://avatars.slack-edge.com/2016-04-27/00000000000_01234567890abcdef012_24.jpg"}},
{"U00000002", "bob", UserProfile{"[email protected]", "Bob", "Doe", "Bob Doe", "Bob Doe", "title2", "https://secure.gravatar.com/avatar/0123456789abcdef0123456789abcdef.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F66f9%2Fimg%2Favatars%2Fava_0002-24.png"}},
Expand All @@ -52,7 +52,7 @@ func TestReadUsers(t *testing.T) {
}

func TestReadHistory(t *testing.T) {
actual := ReadHistory("test_data/channel1/2016-05-18.json")
actual := ReadHistory("testdata/channel1/2016-05-18.json")
expected := []Message{
{"U00000002", "", "Hello", "", "1463564356.000010"},
{"", "B00000001", "Hello <@U00000002|bob>", "bot_message", "1463564356.595611"},
Expand Down

0 comments on commit 18f28bb

Please sign in to comment.