# `rai init` testing

The files in this directory are not currently being used, as of May 2024. They were found to be a little too sensitive to changes in the CLI and would have required frequent rewrites as-is. However, this situation may improve if we do more mocking.

However, here is a manual testing flow that can be used to check `rai init` for issues (note: partly generated by ChatGPT and edited):

1. Start with no `raiconfig.toml` file and run `rai init`. Follow the prompts to set up the `pyrel-testing` Snowflake profile that the team shares.
   1. Check that you get a `raiconfig.toml` file in the current directory. Do `rai config:explain` to make sure you see the parameters you specified, and do `rai config:check` to ensure that the connection works.
2. Now delete the `active_profile` key from the `raiconfig.toml` file, change the profile name to `default`, and run `rai config:explain` again. You should see the default profile still.
3. Run `rai init` again and add an Azure profile. Look at `raiconfig.toml` again and make sure it shows two profiles. Run `rai config:explain` to make sure you're picking up the new one.
Continuing from your testing steps, here's an expanded sequence to thoroughly check the various features of the CLI flow:
4. Introduce a syntax error in `raiconfig.toml` (such as a missing bracket or quote). Run `rai config:explain` to verify that the CLI properly catches and reports the error.
   1. Correct the syntax error and verify that `rai config:explain` now reports no issues.
5. Modify the Azure profile in `raiconfig.toml` by changing the client credentials URL to a non-existent or incorrect URL. Run `rai config:check` and expect it to fail.
   1. Restore the correct URL and verify again with `rai config:check` to ensure the CLI can reconnect successfully.
6. Execute `rai init` to create a new profile but choose the option to use an existing profile when prompted. Verify that the existing profile's settings are duplicated in the new profile without having to re-enter them.
   1. Change a few parameters in the new profile and run `rai config:explain` to ensure the changes are reflected correctly.
7. Test the `gitignore_flow` by ensuring that running `rai init` adds `raiconfig.toml` to the `.gitignore` file if it’s not already there.
8.  Test error handling in the profile naming flow (`name_profile_flow`). Attempt to name a profile using invalid characters and verify that the CLI rejects it with a proper error message.
   1. Attempt to overwrite an existing profile with the confirmation prompt to ensure that the flow handles user input correctly.
9.  Finally, simulate a partial configuration save scenario where `rai init` is aborted mid-way through. Verify that the CLI prompts to save the partial configuration, saves it, and correctly adds it to `raiconfig.toml`.
    1. Check the contents of `raiconfig.toml` after a partial save to ensure it contains the correct partial configuration data.
10. Remove the `[profile.default]` header from one of the profiles and run `rai init` again. Make sure that the newly created profile overrides the keys that were placed into the top level by the deletion of the header. This is important to check since legacy users may have config files that look like this.