run stale repo check as test instead (#4265)

This commit is contained in:
Amir Ariffin 2022-06-10 20:28:34 +08:00 committed by GitHub
parent 462dbbb9e7
commit 1fd356d91f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 9 deletions

View File

@ -13,6 +13,6 @@ jobs:
- name: Get dependencies
run: go get -v -t -d ./...
- name: run script
run: go run test_stale_repositories.go scripts.go
run: go test stale_repositories_test.go scripts.go
env:
OAUTH_TOKEN: ${{secrets.OAUTH_TOKEN}}

1
.gitignore vendored
View File

@ -1,5 +1,6 @@
tmpl/index.html
awesome-go
vendor
# Folders
.idea

View File

@ -2,6 +2,7 @@ package main
import (
"bytes"
"context"
"encoding/json"
"fmt"
"log"
@ -9,6 +10,7 @@ import (
"os"
"regexp"
"strings"
"testing"
"text/template"
"time"
@ -36,8 +38,6 @@ const movedPermanently = " status code 301 received"
const status302 = " status code 302 received"
const archived = " repository has been archived"
var delay time.Duration = 1
//LIMIT specifies the max number of repositories that are added in a single run of the script
var LIMIT = 10
var ctr = 0
@ -140,10 +140,7 @@ func getAllFlaggedRepositories(client *http.Client, flaggedRepositories *map[str
}
func containsOpenIssue(link string, openIssues map[string]bool) bool {
_, ok := openIssues[link]
if ok {
return true
}
return false
return ok
}
func testRepoState(toRun bool, href string, client *http.Client, staleRepos *[]string) bool {
if toRun {
@ -232,7 +229,7 @@ func testStaleRepository() {
tokenSource := &tokenSource{
AccessToken: oauth,
}
client = oauth2.NewClient(oauth2.NoContext, tokenSource)
client = oauth2.NewClient(context.Background(), tokenSource)
}
err := getAllFlaggedRepositories(client, &addressedRepositories)
@ -270,6 +267,6 @@ func testStaleRepository() {
createIssue(staleRepos, client)
}
func main() {
func TestStaleRepository(t *testing.T) {
testStaleRepository()
}