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

Implemented optional data validation #118

Open
wants to merge 20 commits into
base: master
Choose a base branch
from

Conversation

Masken8
Copy link

@Masken8 Masken8 commented Jan 1, 2021

Implemented #64

@Masken8 Masken8 changed the title Implemented optional data validation (#64) Implemented optional data validation #64 Jan 1, 2021
@Masken8 Masken8 changed the title Implemented optional data validation #64 Implemented optional data validation Jan 1, 2021
Copy link
Owner

@Kampfkarren Kampfkarren left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs a unit test as well.

DataStore2/init.lua Outdated Show resolved Hide resolved
DataStore2/init.lua Outdated Show resolved Hide resolved
DataStore2/init.lua Outdated Show resolved Hide resolved
DataStore2/init.lua Outdated Show resolved Hide resolved
DataStore2/init.lua Outdated Show resolved Hide resolved
DataStore2/init.lua Outdated Show resolved Hide resolved
DataStore2/init.lua Outdated Show resolved Hide resolved
DataStore2/init.lua Outdated Show resolved Hide resolved
DataStore2/init.lua Outdated Show resolved Hide resolved
Copy link
Owner

@Kampfkarren Kampfkarren left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for giving you a lot of work, just want to make sure that the DataStore2 codebase is as solid as can be.

Tests/tests/DataStore2.spec.lua Outdated Show resolved Hide resolved
Tests/tests/DataStore2.spec.lua Outdated Show resolved Hide resolved
Tests/tests/DataStore2.spec.lua Outdated Show resolved Hide resolved
DataStore2/init.lua Outdated Show resolved Hide resolved
DataStore2/init.lua Outdated Show resolved Hide resolved
DataStore2/init.lua Outdated Show resolved Hide resolved
DataStore2/init.lua Outdated Show resolved Hide resolved
Tests/tests/DataStore2.spec.lua Outdated Show resolved Hide resolved
Copy link
Owner

@Kampfkarren Kampfkarren left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can click "Add suggestion to batch" to combine them all into one commit, by the way.

DataStore2/init.lua Show resolved Hide resolved
DataStore2/init.lua Show resolved Hide resolved
DataStore2/init.lua Show resolved Hide resolved
DataStore2/init.lua Show resolved Hide resolved
Tests/tests/DataStore2.spec.lua Show resolved Hide resolved
Tests/tests/DataStore2.spec.lua Show resolved Hide resolved
Tests/tests/DataStore2.spec.lua Show resolved Hide resolved
Tests/tests/DataStore2.spec.lua Show resolved Hide resolved
Tests/tests/DataStore2.spec.lua Show resolved Hide resolved
Tests/tests/DataStore2.spec.lua Show resolved Hide resolved
Co-authored-by: boyned//Kampfkarren <[email protected]>
@Kampfkarren
Copy link
Owner

Can you please provide proof that you ran the tests and they pass? I'm trying to get them running on CI.

@Kampfkarren
Copy link
Owner

Tests run on CI now, merge from latest master.

@Kampfkarren
Copy link
Owner

Ugh, that specific error is not your fault. I'll look into it.

@Kampfkarren
Copy link
Owner

I think I don't have the ability to run tests on PRs since you don't have the authentication token, I'm going to clone your branch and test it on there.

@Kampfkarren
Copy link
Owner

Your tests failed--#121

Please make a good attempt to run the tests locally.

All it should take is:

  1. Download the submodules (for TestEZ and MockDataStoreWrapper)
  2. Build tests.project.json into an rbxlx
  3. Open that rbxlx, and click Run
  4. See the output

@Masken8
Copy link
Author

Masken8 commented Jan 2, 2021

I'm getting $path referred to a path that could not be turned into an instance by Rojo and then Rojo crashes

@Kampfkarren
Copy link
Owner

I'd recommend doing a bisect, removing paths from the project.json until it works, so you know which path in specific is causing the issues. Make sure your Rojo is up to date as well.

I know what is causing the test failures, but I want to make sure you know how to run the tests yourself!

@Masken8
Copy link
Author

Masken8 commented Jan 3, 2021

Attempted to set data store to an invalid value during :Set

Attempted to set data store to an invalid value during :Update

TestService: ServerScriptService.Tests.Tests.DataStore2.spec:96: Expected function to throw an error containing "Attempted to set data store to an invalid value during :Set", but it threw: attempt to call a table value

ServerScriptService.Tests.TestEZ.Expectation:47 function assertLevel
ServerScriptService.Tests.TestEZ.Expectation:305 function throw
ServerScriptService.Tests.TestEZ.Expectation:59
ServerScriptService.Tests.Tests.DataStore2.spec:96
ServerScriptService.Tests.TestEZ.TestRunner:86
ServerScriptService.Tests.TestEZ.TestRunner:84 function runCallback
ServerScriptService.Tests.TestEZ.TestRunner:116 function runNode
ServerScriptService.Tests.TestEZ.TestRunner:153 function runPlanNode
ServerScriptService.Tests.TestEZ.TestRunner:164 function runPlanNode
ServerScriptService.Tests.TestEZ.TestRunner:164 function runPlanNode
ServerScriptService.Tests.TestEZ.TestRunner:164 function runPlanNode
ServerScriptService.Tests.TestEZ.TestRunner:164 function runPlanNode
ServerScriptService.Tests.TestEZ.TestRunner:45 function runPlan
ServerScriptService.Tests.TestEZ.TestBootstrap:127 function run
ServerScriptService.Tests.Tests.TestRunner:5

TestService: ServerScriptService.Tests.Tests.DataStore2.spec:116: Expected function to throw an error containing "Attempted to set data store to an invalid value during :Update", but it threw: attempt to call a nil value

ServerScriptService.Tests.TestEZ.Expectation:47 function assertLevel
ServerScriptService.Tests.TestEZ.Expectation:305 function throw
ServerScriptService.Tests.TestEZ.Expectation:59
ServerScriptService.Tests.Tests.DataStore2.spec:116
ServerScriptService.Tests.TestEZ.TestRunner:86
ServerScriptService.Tests.TestEZ.TestRunner:84 function runCallback
ServerScriptService.Tests.TestEZ.TestRunner:116 function runNode
ServerScriptService.Tests.TestEZ.TestRunner:153 function runPlanNode
ServerScriptService.Tests.TestEZ.TestRunner:164 function runPlanNode
ServerScriptService.Tests.TestEZ.TestRunner:164 function runPlanNode
ServerScriptService.Tests.TestEZ.TestRunner:164 function runPlanNode
ServerScriptService.Tests.TestEZ.TestRunner:164 function runPlanNode
ServerScriptService.Tests.TestEZ.TestRunner:45 function runPlan
ServerScriptService.Tests.TestEZ.TestBootstrap:127 function run
ServerScriptService.Tests.Tests.TestRunner:5

How, I cannot for the life of me figure this out.

Edit: Might have figured it out
Edit 2: or not

@Kampfkarren
Copy link
Owner

Request review from me when you have something that works so I can run it on the CI runner.

@Masken8
Copy link
Author

Masken8 commented Jan 9, 2021

I have been trying to figure this out for a week now and I'm still none the wiser. I'm still stuck with the cryptic error messages above. The same code without the unit testing works completely fine though so the errors must be caused by TestEZ somehow 🤔

end

dataStore:SetValidator(testValidator)
expect(dataStore:Set("nope")).to.throw("Attempted to set data store to an invalid value during :Set")
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't how .to.throw works, if dataStore:Set("nope") errors then it would error the entire script!

image

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You need the function there because that's what's actually pcalled. The way you have it now looks like :Set returns a function that you're checking.

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.

2 participants