diff options
author | Christopher Baines <mail@cbaines.net> | 2020-02-14 09:18:28 +0000 |
---|---|---|
committer | Christopher Baines <mail@cbaines.net> | 2020-02-14 09:18:28 +0000 |
commit | f6f51bbe0dc89dfec6d1d6e74818ad1f9c2d6dbc (patch) | |
tree | f176b42c47b4b7e136fedd9f302bf560249c445c /tests | |
parent | 374dc25440efaef619cdc8d3288261c20ce45858 (diff) | |
download | data-service-f6f51bbe0dc89dfec6d1d6e74818ad1f9c2d6dbc.tar data-service-f6f51bbe0dc89dfec6d1d6e74818ad1f9c2d6dbc.tar.gz |
Fake the store connection in the tests
So that the tests don't require a store connection.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/jobs-load-new-guix-revision.scm | 157 |
1 files changed, 89 insertions, 68 deletions
diff --git a/tests/jobs-load-new-guix-revision.scm b/tests/jobs-load-new-guix-revision.scm index e101bce..859c63f 100644 --- a/tests/jobs-load-new-guix-revision.scm +++ b/tests/jobs-load-new-guix-revision.scm @@ -3,6 +3,7 @@ #:use-module (ice-9 match) #:use-module (squee) #:use-module (guix utils) + #:use-module (guix store) #:use-module (guix tests) #:use-module (guix-data-service database) #:use-module (tests mock-inferior) @@ -11,6 +12,8 @@ (test-begin "jobs-load-new-guix-revision") +(%daemon-socket-uri "/var/empty/doesnotexist") + (with-postgresql-connection "test-jobs-load-new-guix-revision" (lambda (conn) @@ -24,44 +27,50 @@ #t (mock ((guix-data-service jobs load-new-guix-revision) - channel->derivations-by-system - (lambda (conn store channel) - '((x86_64-linux - . - ((manifest-entry-item . /gnu/store/foo.drv) - (profile . /gnu/store/bar.drv)))))) + with-store-connection + (lambda (f) + (f 'fake-store-connection))) (mock ((guix-data-service jobs load-new-guix-revision) - channel-derivations-by-system->guix-store-item - (lambda (store channel-derivations-by-system) - "/gnu/store/test")) + channel->derivations-by-system + (lambda (conn store channel) + '((x86_64-linux + . + ((manifest-entry-item . /gnu/store/foo.drv) + (profile . /gnu/store/bar.drv)))))) (mock ((guix-data-service jobs load-new-guix-revision) - extract-information-from - (lambda (conn store guix-revision-id commit store-path) - #t)) + channel-derivations-by-system->guix-store-item + (lambda (store channel-derivations-by-system) + "/gnu/store/test")) (mock - ((guix-data-service model channel-instance) - insert-channel-instances - (lambda (conn guix-revision-id derivations-by-system) + ((guix-data-service jobs load-new-guix-revision) + extract-information-from + (lambda (conn store guix-revision-id commit store-path) #t)) (mock - ((guix channels) - channel-news-for-commit - (lambda (channel commit) - '())) - - (match (enqueue-load-new-guix-revision-job - conn - (git-repository-url->git-repository-id conn "test-url") - "test-commit" - "test-source") - ((id) - (process-load-new-guix-revision-job id))))))))) + ((guix-data-service model channel-instance) + insert-channel-instances + (lambda (conn guix-revision-id derivations-by-system) + #t)) + + (mock + ((guix channels) + channel-news-for-commit + (lambda (channel commit) + '())) + + (match (enqueue-load-new-guix-revision-job + conn + (git-repository-url->git-repository-id conn "test-url") + "test-commit" + "test-source") + ((id) + (process-load-new-guix-revision-job id)))))))))) (exec-query conn "TRUNCATE guix_revisions CASCADE") (exec-query conn "TRUNCATE load_new_guix_revision_jobs CASCADE") @@ -70,26 +79,32 @@ #f (mock ((guix-data-service jobs load-new-guix-revision) - channel->derivations-by-system - (lambda (conn store channel) - '(x86_64-linux - . - ((manifest-entry-item . /gnu/store/foo.drv) - (profile . /gnu/store/bar.drv))))) + with-store-connection + (lambda (f) + (f 'fake-store-connection))) (mock ((guix-data-service jobs load-new-guix-revision) - channel-derivations-by-system->guix-store-item - (lambda (store channel-derivations-by-system) - #f)) - - (match (enqueue-load-new-guix-revision-job - conn - (git-repository-url->git-repository-id conn "test-url") - "test-commit" - "test-source") - ((id) - (process-load-new-guix-revision-job id)))))) + channel->derivations-by-system + (lambda (conn store channel) + '(x86_64-linux + . + ((manifest-entry-item . /gnu/store/foo.drv) + (profile . /gnu/store/bar.drv))))) + + (mock + ((guix-data-service jobs load-new-guix-revision) + channel-derivations-by-system->guix-store-item + (lambda (store channel-derivations-by-system) + #f)) + + (match (enqueue-load-new-guix-revision-job + conn + (git-repository-url->git-repository-id conn "test-url") + "test-commit" + "test-source") + ((id) + (process-load-new-guix-revision-job id))))))) (exec-query conn "TRUNCATE load_new_guix_revision_jobs CASCADE") @@ -97,38 +112,44 @@ #f (mock ((guix-data-service jobs load-new-guix-revision) - channel->derivations-by-system - (lambda (conn store channel) - '(x86_64-linux - . - ((manifest-entry-item . /gnu/store/foo.drv) - (profile . /gnu/store/bar.drv))))) + with-store-connection + (lambda (f) + (f 'fake-store-connection))) (mock ((guix-data-service jobs load-new-guix-revision) - channel-derivations-by-system->guix-store-item - (lambda (store channel-derivations-by-system) - "/gnu/store/test")) + channel->derivations-by-system + (lambda (conn store channel) + '(x86_64-linux + . + ((manifest-entry-item . /gnu/store/foo.drv) + (profile . /gnu/store/bar.drv))))) (mock ((guix-data-service jobs load-new-guix-revision) - extract-information-from - (lambda (conn store git-repository-id commit store-path) - #f)) + channel-derivations-by-system->guix-store-item + (lambda (store channel-derivations-by-system) + "/gnu/store/test")) (mock - ((guix channels) - channel-news-for-commit - (lambda (channel commit) - '())) - - (match (enqueue-load-new-guix-revision-job - conn - (git-repository-url->git-repository-id conn "test-url") - "test-commit" - "test-source") - ((id) - (process-load-new-guix-revision-job id)))))))) + ((guix-data-service jobs load-new-guix-revision) + extract-information-from + (lambda (conn store git-repository-id commit store-path) + #f)) + + (mock + ((guix channels) + channel-news-for-commit + (lambda (channel commit) + '())) + + (match (enqueue-load-new-guix-revision-job + conn + (git-repository-url->git-repository-id conn "test-url") + "test-commit" + "test-source") + ((id) + (process-load-new-guix-revision-job id))))))))) (exec-query conn "TRUNCATE load_new_guix_revision_jobs CASCADE") |