diff --git a/.woodpecker/.test.yml b/.woodpecker/.test.yml new file mode 100644 index 0000000..ec559c8 --- /dev/null +++ b/.woodpecker/.test.yml @@ -0,0 +1,15 @@ +matrix: + PLATFORM: + - linux/amd64 + - linux/arm64 + +platform: ${PLATFORM} + +pipeline: + test: + image: 'chewingbever/vlang:latest' + pull: true + commands: + - make test + when: + event: push diff --git a/src/cron/cron.v b/src/cron/cron.v index ccb8f9e..13fc22d 100644 --- a/src/cron/cron.v +++ b/src/cron/cron.v @@ -5,7 +5,7 @@ import datatypes import time struct ScheduledBuild { - repo git.GitRepo + repo git.GitRepo timestamp time.Time } @@ -27,6 +27,6 @@ pub fn cron(conf Config) ? { // } // println(queue) - exp := "10/2 5 *" + exp := '10/2 5 *' println(parse_expression(exp) ?) } diff --git a/src/cron/expression.v b/src/cron/expression.v index 8dae499..2938dd9 100644 --- a/src/cron/expression.v +++ b/src/cron/expression.v @@ -4,8 +4,8 @@ import math struct CronExpression { minutes []u32 - hours []u32 - days []u32 + hours []u32 + days []u32 } // parse_range parses a given string into a range of integers, if possible. @@ -22,7 +22,7 @@ fn parse_range(s string, min u32, max u32) ?[]u32 { } // Here, s solely consists of a number, so that's the only value we // should return. - else{ + else { return [exps[0].u32()] } @@ -44,7 +44,7 @@ fn parse_expression(exp string) ?CronExpression { parts := exp.split(' ') if parts.len != 3 { - return error("Expression must contain 5 space-separated parts.") + return error('Expression must contain 5 space-separated parts.') } return CronExpression{ diff --git a/src/cron/expression_test.v b/src/cron/expression_test.v index b3b7422..562ced2 100644 --- a/src/cron/expression_test.v +++ b/src/cron/expression_test.v @@ -1,5 +1,9 @@ module cron -fn test_parse_star_range() { - assert parse_range('*', 0, 5) == [0, 1, 2, 3, 4, 5] +fn test_parse_star_range() ? { + assert parse_range('*', 0, 5) ? == [u32(0), 1, 2, 3, 4, 5] +} + +fn test_parse_number() ? { + assert parse_range('4', 0, 5) ? == [u32(4)] } diff --git a/src/env.v b/src/env/env.v similarity index 100% rename from src/env.v rename to src/env/env.v diff --git a/src/package.v b/src/package/package.v similarity index 100% rename from src/package.v rename to src/package/package.v diff --git a/src/response.v b/src/response/response.v similarity index 100% rename from src/response.v rename to src/response/response.v diff --git a/src/util.v b/src/util/util.v similarity index 100% rename from src/util.v rename to src/util/util.v