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

creating an rfc for testing #5540

Open
tsuf239 opened this issue Jan 25, 2024 · 1 comment · May be fixed by #5576
Open

creating an rfc for testing #5540

tsuf239 opened this issue Jan 25, 2024 · 1 comment · May be fixed by #5576
Labels
✨ enhancement New feature or request needs-discussion Further discussion is needed prior to impl 🧪 testing

Comments

@tsuf239
Copy link
Collaborator

tsuf239 commented Jan 25, 2024

Use Case

following 25/01/24 team time - we can only make wing's testing framework great if someone owns it, I'll collect the relevant issues and try my best to create a solid rfc out of them 💪

Proposed Solution

No response

Implementation Notes

No response

Component

No response

Community Notes

  • Please vote by adding a 👍 reaction to the issue to help us prioritize.
  • If you are interested to work on this issue, please leave a comment.
  • If this issue is labeled needs-discussion, it means the spec has not been finalized yet. Please reach out on the #dev channel in the Wing Slack.
@tsuf239 tsuf239 added ✨ enhancement New feature or request needs-discussion Further discussion is needed prior to impl labels Jan 25, 2024
@tsuf239 tsuf239 self-assigned this Jan 25, 2024
@ekeren
Copy link
Collaborator

ekeren commented Jan 25, 2024

Here are my two cents:

  • test is for preflight code blocks, this keyword is only available in *.test.w files and it creates an isolated environment that can run checks
  • check (or maybe monitor) is for inflight code, nested inside a test block or inside any *.main.w file

test runs in isolation (a test doesn't interfere another test) while check run on the same INFA, and there is no guarantee on order and parallelism .

// *.main.w
bring cloud;
bring util;
bring expect;

let b = new cloud.Bucket();

check "bucket put and get" {
  // check doesn't run in isolation, so a unique file is required
  let file = util.uuidv4(); 
  b.put(file, "1234");
  expect.equal(b.get(file), "1234");
}

check "list bucket" {
  let file = util.uuidv4(); 
  b.put(file, "1234");
  let files = b.list(); // will return a list of more then this file
  assert(files.contains(file));
}

check "this is a bad test" {
  // this check will fail in some cases, depending which check will run first
  expect.equal(b.list().length, 0);
}
// *.test.w
bring cloud;
bring util;
bring expect;

test "empty bucket" {
  let b = new cloud.Bucket();
  
  check "list is empty" {
    expect.equal(b.list().length, 0);
  }
} 

test "bucket addObject" {
  let b = new cloud.Bucket();
  let file = "file";
  b.addObject(file ,"xyz");
  check "list return 1" {
    expect.equal(b.list().length, 1);
    expect.equal(b.list().at(0), file);
  }
  check "add object returns right content" {
    expect.equal(b.get(file), "xyz");
  }
} 

@tsuf239 tsuf239 linked a pull request Jan 30, 2024 that will close this issue
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
✨ enhancement New feature or request needs-discussion Further discussion is needed prior to impl 🧪 testing
Projects
Status: 🏗 In progress
Development

Successfully merging a pull request may close this issue.

3 participants