Skip to content

Commit

Permalink
Update application testing
Browse files Browse the repository at this point in the history
  • Loading branch information
jodyheavener committed Apr 2, 2024
1 parent b8a6289 commit 5cb74ba
Show file tree
Hide file tree
Showing 22 changed files with 619 additions and 569 deletions.
6 changes: 3 additions & 3 deletions script/application.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func (a *Application) Parse(issue *github.Issue) {

a.sections = a.extractSections(*issue.Body)

if isTestingIssue() {
if isTesting() {
data, err := json.MarshalIndent(a.sections, "", "\t")
if err != nil {
log.Fatalf("Could not marshal Sections input data: %s", err.Error())
Expand Down Expand Up @@ -99,7 +99,7 @@ func (a *Application) Parse(issue *github.Issue) {

a.CanContact = a.boolSection("Can we contact you?", false, ParseCheckbox)

if isTestingIssue() {
if isTesting() {
debugMessage("Application data:", string(a.GetData()))
}

Expand Down Expand Up @@ -149,7 +149,7 @@ func (a *Application) FileName() string {
}

func (a *Application) SetApprover() error {
if isTestingIssue() {
if isTesting() {
a.ApproverId = 123
a.ApproverUsername = "test-username"

Expand Down
19 changes: 7 additions & 12 deletions script/application_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,11 @@ func TestApplication(t *testing.T) {
expectedValid: true,
},
{
name: "project-character-test",
name: "character-test",
expectedValid: true,
},
{
name: "empty-body",
name: "no-body",
expectedValid: false,
expectedProblems: []error{
errIncomplete("Account URL"),
Expand Down Expand Up @@ -113,7 +113,7 @@ func TestApplication(t *testing.T) {
},
},
{
name: "examples-1",
name: "invalid-1",
expectedValid: false,
expectedProblems: []error{
errNoProjectName("Application title"),
Expand All @@ -130,19 +130,14 @@ func TestApplication(t *testing.T) {
t.Run(tt.name, func(t *testing.T) {
application := Application{}

if tt.expectedValid {
testIssueName = fmt.Sprintf("valid-%s", tt.name)
} else {
testIssueName = fmt.Sprintf("invalid-%s", tt.name)
}

application.Parse(getTestIssue())
setTestApplication(tt.name)
application.Parse(testIssue)

if application.IsValid() != tt.expectedValid {
if tt.expectedValid {
t.Errorf("Test issue '%s' is invalid, expected valid", testIssueName)
t.Errorf("Test issue '%s' is invalid, expected valid", tt.name)
} else {
t.Errorf("Test issue '%s' is valid, expected invalid", testIssueName)
t.Errorf("Test issue '%s' is valid, expected invalid", tt.name)
}
}

Expand Down
14 changes: 7 additions & 7 deletions script/github.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ type GitHub struct {
}

func (g *GitHub) Init() error {
if isTestingIssue() {
if isTesting() {
debugMessage("Skipping GitHub Init")
g.Issue = getTestIssue()
g.Issue = testIssue
return nil
}

Expand Down Expand Up @@ -73,7 +73,7 @@ func (g *GitHub) Init() error {
}

func (g *GitHub) CreateIssueComment(message string) error {
if isTestingIssue() {
if isTesting() {
botMessage(message)
return nil
}
Expand Down Expand Up @@ -102,7 +102,7 @@ func (g *GitHub) IssueHasLabel(label string) bool {
}

func (g *GitHub) AddIssueLabel(label string) error {
if isTestingIssue() {
if isTesting() {
debugMessage(fmt.Sprintf("Adding label \"%s\"", label))
return nil
}
Expand All @@ -119,7 +119,7 @@ func (g *GitHub) AddIssueLabel(label string) error {
}

func (g *GitHub) RemoveIssueLabel(label string) error {
if isTestingIssue() {
if isTesting() {
debugMessage(fmt.Sprintf("Removing label \"%s\"", label))
return nil
}
Expand All @@ -136,7 +136,7 @@ func (g *GitHub) RemoveIssueLabel(label string) error {
}

func (g *GitHub) CloseIssue() error {
if isTestingIssue() {
if isTesting() {
debugMessage("Closing issue")
return nil
}
Expand All @@ -157,7 +157,7 @@ func (g *GitHub) CloseIssue() error {
func (g *GitHub) CommitNewFile(filePath string, content []byte, message string) error {
commitBranch := "main"

if isTestingIssue() {
if isTesting() {
debugMessage(
fmt.Sprintf(
"Commiting the following contents to a file located at \"%s\" with the commit message \"%s\":",
Expand Down
7 changes: 3 additions & 4 deletions script/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
)

func printUsageAndExit() {
log.Fatal("Usage: ./processor <review|approve> [--test-issue <issue name>]")
log.Fatal("Usage: ./processor <review|approve> [--test <name>]")
}

func getEnv(key string) (string, error) {
Expand All @@ -27,9 +27,8 @@ func main() {

command := os.Args[1]

if len(os.Args) == 4 && os.Args[2] == "--test-issue" {
testIssueName = os.Args[3]
debugMessage(fmt.Sprintf("Using test issue '%s'", testIssueName))
if len(os.Args) == 4 && os.Args[2] == "--test" {
setTestApplication(os.Args[3])
} else if len(os.Args) != 2 {
printUsageAndExit()
}
Expand Down
73 changes: 73 additions & 0 deletions script/mock-issue-bodies/character-test.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
### Account URL

`testdb.1password.com`

### Non-commercial confirmation

- [X] No, this account won't be used for commercial activity

### 👨‍💻 Team application

- [X] Yes, this application is for a team

### Event application

- [ ] Yes, this application is for an event

### Project name

`_TestDB_\n\n- test``

### Short description

TestDB is a free and open source, community-based forum software project.```

## **This is a test comment** <img src=\"howdy.png\" />

### Number of team members/core contributors

1

### Homepage URL

https://github.com/wendyappleed/test-db

### Repository URL

[https://github.com/wendyappleed/test-db](https://github.com/wendyappleed/test-db)

### License type

MIT

### License URL

https://github.com/wendyappleed/test-db/blob/main/LICENSE.md

### Age confirmation

- [X] Yes, this project is at least 30 days old

### Name

Wendy Appleseed

### Email

[email protected]

### Project role

Core Maintainer

### Profile or website

https://github.com/wendyappleseed/

### Can we contact you?

- [X] Yes, you may contact me

### Additional comments

Thank you!
73 changes: 73 additions & 0 deletions script/mock-issue-bodies/event.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
### Account URL

fooconf.1password.eu

### Non-commercial confirmation

- [X] No, this account won't be used for commercial activity

### Team application

- [ ] Yes, this application is for a team

### Event application

- [X] Yes, this application is for an event

### Project name

FooConf

### Short description

**Foo Conference** is a non-profit conference targeting Designers and Frontend engineers taking place yearly in Zurich.

As a not-for-profit community event we rely on volunteers to enable us to run a great event.

### Number of team members/core contributors

11

### Homepage URL

https://fooconf.com/

### Repository URL

_No response_

### License type

_No response_

### License URL

_No response_

### Age confirmation

- [ ] Yes, this project is at least 30 days old

### Name

Wendy Appleseed

### Email

[email protected]

### Project role

Organizer or Admin

### Profile or website

_No response_

### Can we contact you?

- [X] Yes, you may contact me

### Additional comments

_No response_
71 changes: 71 additions & 0 deletions script/mock-issue-bodies/invalid-1.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
### Account URL

foo

### Non-commercial confirmation

- [ ] No, this account won't be used for commercial activity

### Team application

- [ ] Yes, this application is for a team

### Event application

- [ ] Yes, this application is for an event

### Project name

TestDB 🎁

### Short description

[TestDB](https://testdb.com) is a free and open source, community-based forum software project.

### Number of team members/core contributors

foo

### Homepage URL

@wendyappleed

### Repository URL

https://github.com/wendyappleed/test-db

### License type

MIT

### License URL

https://github.com/wendyappleed/test-db/blob/main/LICENSE.md

### Age confirmation

- [X] Yes, this project is at least 30 days old

### Name

Wendy Appleseed

### Email

[email protected]

### Project role

Lead Dev

### Profile or website

https://github.com/wendyappleseed/

### Can we contact you?

- [X] Yes, you may contact me

### Additional comments

Thank you! ✨
Loading

0 comments on commit 5cb74ba

Please sign in to comment.