Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add error message testing arm #6908

Merged
merged 2 commits into from
Jul 8, 2024
Merged

Add error message testing arm #6908

merged 2 commits into from
Jul 8, 2024

Conversation

sigilante
Copy link
Contributor

Target tested code:

++  fail
  |=  *
  ~|(%an-error-message !!)

Usage in a test thread:

++  test-failure
    %+  expect-fail-message
      %an-error-message                                                         
    |.  (fail:main ~)

A recursive +find could make this less cumbersome.

@sigilante sigilante marked this pull request as ready for review February 7, 2024 19:49
@jackfoxy
Copy link

jackfoxy commented Feb 10, 2024

This works for "vanilla" test failure

++  test-fail-time-create-ns-lt-schema
  =|  run=@ud
  =/  my-cmd  "CREATE NAMESPACE ns1 as of ~2023.7.9..22.35.33..7e90"
  %+  expect-fail-message
      'namespace %ns1 as-of schema time out of order'
      |.  %-  process-cmds 
              :+  gen3-dbs
                  (bowl [run ~2031.1.1])
                  (parse:parse(default-database 'db1') my-cmd)

But not testing a poke

++  test-fail-time-create-ns-lt-schema
  =|  run=@ud
  =^  mov1  agent  
    %:  ~(on-poke agent (bowl [run ~2000.1.1]))
        %obelisk-action
        !>  :-  %tape-create-db 
                "CREATE DATABASE db1 as of ~2023.7.9..22.35.35..7e90"
    ==
  =.  run  +(run)
  %+  expect-fail-message
      'namespace %ns1 as-of schema time out of order'
      |.  %:  ~(on-poke agent (bowl [run ~2000.1.2]))
              %obelisk-action
              !>  :-  %tape-create-db
                      "CREATE NAMESPACE ns1 as of ~2023.7.9..22.35.34..7e90"
          ==

@sigilante
Copy link
Contributor Author

An agent is going to route through ++on-fail. Offhand I think you'd have to test whatever state change or result that ++on-fail produces.

@jackfoxy
Copy link

Yet changing the expect-fail-message step to expect-eq fails with a stack trace containing the expected message.

@sigilante sigilante merged commit cb51197 into develop Jul 8, 2024
@sigilante sigilante deleted the sigilante/testing-errors branch July 8, 2024 19:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants