Skip to content

Commit

Permalink
fix test workflow (#3)
Browse files Browse the repository at this point in the history
* fix: add build

* build: further fixes hopefully

* build: further fixes

* fix: run where the renv env be

* test: update tests to work with workflow
  • Loading branch information
sof202 authored Sep 19, 2024
1 parent 2fb2dc8 commit 1c216ba
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 16 deletions.
13 changes: 7 additions & 6 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@ on:
branches: [ "main" ]
workflow_dispatch:

permissions:
contents: read
jobs:
build:
runs-on: ubuntu-latest

permissions:
contents: read

steps:
- name: Checkout code
uses: actions/checkout@v4
Expand All @@ -20,12 +22,11 @@ jobs:
uses: r-lib/actions/setup-r@v2

- name: Install dependencies
uses: r-lib/actions/setup-r-dependencies@v2
working-directory: chrombinarize
uses: r-lib/actions/setup-renv@v2

- name: Run tests
run: |
library(testthat)
library(chrombinarize)
test_dir("tests/testthat")
working-directory: chrombinarize
test_dir("chrombinarize/tests/testthat")
shell: Rscript {0}
26 changes: 22 additions & 4 deletions chrombinarize/tests/testthat/test-CPG_robustness_plots.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ test_that("Normal functionality is obtained for data creation", {
"expected_bedmethyl_data.Rds"
))
actual_cpg_robustness_data <-
create_cpg_robustness_data(methylation_data, 0, 1000)
chrombinarize:::create_cpg_robustness_data(methylation_data, 0, 1000)
expected_cpg_robustness_data <- readRDS(test_path(
"test_data",
"cpg_robustness",
Expand All @@ -28,16 +28,34 @@ test_that("Edge cases are handled as expected", {

# Filtering steps will always leave an empty data frame
expect_no_error(
calculate_nearby_methylation(methylation_data, "chr1", 1000, 0, 0)
chrombinarize:::calculate_nearby_methylation(
methylation_data,
"chr1",
1000,
0,
0
)
)

# Chromosome doesn't exist
expect_no_error(
calculate_nearby_methylation(methylation_data, "chrZ", 1000, 0, 0)
chrombinarize:::calculate_nearby_methylation(
methylation_data,
"chrZ",
1000,
0,
30
)
)

# Base pair position doesn't exist
expect_no_error(
calculate_nearby_methylation(methylation_data, "chr1", -1, 0, 0)
chrombinarize:::calculate_nearby_methylation(
methylation_data,
"chr1",
-1,
0,
30
)
)
})
3 changes: 2 additions & 1 deletion chrombinarize/tests/testthat/test-ONT_BS_comparison_plots.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ test_that("New columns added are as expected", {
"read_comparison_files",
"expected_comparitive_bedmethyl.Rds"
))
actual_updated_columns <- add_absolute_change_columns(methylation_data)
actual_updated_columns <-
chrombinarize:::add_absolute_change_columns(methylation_data)
expected_updated_columns <- readRDS(test_path(
"test_data",
"ONT_BS_comparison",
Expand Down
9 changes: 5 additions & 4 deletions chrombinarize/tests/testthat/test-create_blank_bed_data.R
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
# Test data is a subset of hg19.txt that contains chromosomes 1-22, X and Y
chromosome_sizes_test_file <-
testthat::test_path("test_data", "example_chromsizes.txt")
test_path("test_data", "example_chromsizes.txt")

# This test bed data only includes chromosome 1 as it allows for a smaller
# rds file
expected_small_bed_data <-
readRDS(testthat::test_path("test_data", "expected_bed_data.Rds"))
readRDS(test_path("test_data", "expected_bed_data.Rds"))

expected_chromosome_lengths <-
readRDS(testthat::test_path("test_data", "expected_chromosome_lengths.Rds"))
readRDS(test_path("test_data", "expected_chromosome_lengths.Rds"))

testthat::test_that("Processing function returns correct vector", {
chromosome_lengths <- process_chromosome_sizes(chromosome_sizes_test_file)
chromosome_lengths <-
chrombinarize:::process_chromosome_sizes(chromosome_sizes_test_file)

expect_true(is.integer(chromosome_lengths))
expect_equal(
Expand Down
3 changes: 2 additions & 1 deletion chrombinarize/tests/testthat/test-error_rate_plots.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ test_that("Expected value is obtained", {
"read_bedmethyl_files",
"expected_bedmethyl_data.Rds"
))
actual_error_rate_data <- create_error_rate_data(methylation_data, 60, 5)
actual_error_rate_data <-
chrombinarize:::create_error_rate_data(methylation_data, 60, 5)
expected_error_rate_data <- readRDS(test_path(
"test_data",
"error_rate_plot_data",
Expand Down

0 comments on commit 1c216ba

Please sign in to comment.