-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11 from austin1237/regular-expression
regular expression used instead of string.Contains and added tests.
- Loading branch information
Showing
2 changed files
with
57 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package interest | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestCheckIfInterested(t *testing.T) { | ||
tests := []struct { | ||
name string | ||
description string | ||
want bool | ||
}{ | ||
{ | ||
name: "contains typescript", | ||
description: "This is a job for a TypeScript developer", | ||
want: true, | ||
}, | ||
{ | ||
name: "contains node", | ||
description: "This is a job for a Node.js developer", | ||
want: true, | ||
}, | ||
{ | ||
name: "contains go", | ||
description: "This is a job for a Go developer", | ||
want: true, | ||
}, | ||
{ | ||
name: "contains go", | ||
description: "This is a job for go.", | ||
want: true, | ||
}, | ||
{ | ||
name: "contains django", | ||
description: "This is a job for a django developer in Chicago", | ||
want: false, | ||
}, | ||
{ | ||
name: "does not contain keyword", | ||
description: "This is a job for a Python developer", | ||
want: false, | ||
}, | ||
} | ||
|
||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
assert.Equal(t, tt.want, CheckIfInterested(tt.description)) | ||
}) | ||
} | ||
} |