Skip to content

Commit

Permalink
Merge pull request #122 from alidevhere/main
Browse files Browse the repository at this point in the history
issue #87
  • Loading branch information
ezeoleaf authored May 13, 2023
2 parents cebaf15 + 6347e51 commit b0dda57
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
5 changes: 5 additions & 0 deletions provider/github/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,11 @@ func (p Provider) getContent(repo *github.Repository) *domain.Content {
c.ExtraData = append(c.ExtraData, author)
}

if repo.UpdatedAt != nil {
lastUpdatedAt := "Updated on : " + repo.GetUpdatedAt().Format("2006-01-02")
c.ExtraData = append(c.ExtraData, lastUpdatedAt)
}

hs := p.Config.GetHashtags()
hashtags := ""

Expand Down
11 changes: 9 additions & 2 deletions provider/github/provider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ func TestGetRepoUser(t *testing.T) {
func TestGetContent(t *testing.T) {
login, lang, url, name, desc := "t2", "g", "url", "repo", "desc"
count := 1
updatedAt, _ := time.Parse("2006-01-02", "2000-07-12")
gu := github.User{Login: &login}
for _, tc := range []struct {
Name string
Expand Down Expand Up @@ -267,6 +268,12 @@ func TestGetContent(t *testing.T) {
repo: &github.Repository{Name: &name, Description: &desc, Language: &lang, HTMLURL: &url},
returnValue: &domain.Content{Title: &name, Subtitle: &desc, URL: &url, ExtraData: []string{"Lang: g", "#g "}},
},
{
Name: "Test no repo data with only updated at",
mockConfig: config.Config{},
repo: &github.Repository{Language: &lang, HTMLURL: &url, UpdatedAt: &github.Timestamp{Time: updatedAt}},
returnValue: &domain.Content{URL: &url, ExtraData: []string{"Updated on : 2000-07-12", "#g "}},
},
{
Name: "Test full with username",
mockConfig: config.Config{TweetLanguage: true},
Expand All @@ -277,8 +284,8 @@ func TestGetContent(t *testing.T) {
return &u, nil, nil
},
},
repo: &github.Repository{Name: &name, Description: &desc, Language: &lang, HTMLURL: &url, StargazersCount: &count, Owner: &gu},
returnValue: &domain.Content{Title: &name, Subtitle: &desc, URL: &url, ExtraData: []string{"Lang: g", "⭐️ 1", "Author: @twitterusername", "#g "}},
repo: &github.Repository{Name: &name, Description: &desc, Language: &lang, HTMLURL: &url, StargazersCount: &count, Owner: &gu, UpdatedAt: &github.Timestamp{Time: updatedAt}},
returnValue: &domain.Content{Title: &name, Subtitle: &desc, URL: &url, ExtraData: []string{"Lang: g", "⭐️ 1", "Author: @twitterusername", "Updated on : 2000-07-12", "#g "}},
},
} {
t.Run(tc.Name, func(t *testing.T) {
Expand Down

0 comments on commit b0dda57

Please sign in to comment.