Skip to content

Commit

Permalink
Roll some unit tests..
Browse files Browse the repository at this point in the history
  • Loading branch information
coatless committed Jan 15, 2018
1 parent b7d667c commit 69051de
Show file tree
Hide file tree
Showing 2 changed files with 81 additions and 0 deletions.
4 changes: 4 additions & 0 deletions tests/testthat.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
library(testthat)
library(searcher)

test_check("searcher")
77 changes: 77 additions & 0 deletions tests/testthat/test-searcher.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
context("searcher")

test_that("Check link generation", {

##### Google

expect_identical(
search_google("toad"),
"https://google.com/search?q=toad"
)

##### Bing

expect_identical(
search_bing("toad"),
"https://bing.com/search?q=toad"
)

##### DDG

expect_identical(
search_duckduckgo("toad"),
"https://duckduckgo.com/?q=toad"
)

##### StackOverflow

expect_identical(
search_stackoverflow("toad"),
"https://stackoverflow.com/search?q=toad%20[r]"
)

expect_identical(
search_stackoverflow("toad", rlang = FALSE),
"https://stackoverflow.com/search?q=toad"
)

##### GitHub

expect_identical(
search_github("toad"),
"https://github.com/search?q=toad%20language:r%20type:issue&type=Issues"
)

expect_identical(
search_github("toad", rlang = FALSE),
"https://github.com/search?q=toad&type=Issues"
)

##### BitBucket

expect_identical(
search_bitbucket("toad"),
"https://bitbucket.com/search?q=toad%20lang:r"
)

expect_identical(
search_bitbucket("toad", rlang = FALSE),
"https://bitbucket.com/search?q=toad"
)

})


test_that("Malformed search query validation", {
expect_identical(
search_google(""),
"",
"Empty string check if no error messages"
)

expect_identical(
search_google(NULL),
"",
"NULL value handling"
)
})

0 comments on commit 69051de

Please sign in to comment.