diff --git a/docs/ModelUnitTests.md b/docs/ModelUnitTests.md index 3a553d145..5e6e8a70d 100644 --- a/docs/ModelUnitTests.md +++ b/docs/ModelUnitTests.md @@ -1,6 +1,6 @@ # Model Unit Tests Oxidized includes automated unit tests for its models, which require very little -effort to use. There are three different unit tests for models: +effort to use. There are three different default unit tests for models: - [Device Simulation](ModelUnitTests.md#device-simulation) - [Device Prompt](ModelUnitTests.md#device-prompt) - [Secrets](ModelUnitTests.md#secrets) @@ -11,6 +11,9 @@ and the tests will be run automatically with `rake test`. See development environment. In the following examples, we use [Bundler](https://bundler.io/) and prefix all commands with `bundle exec`. +In addition, you can write [custom unit tests](ModelUnitTests.md#custom-tests) +for your model + ## Device Simulation ### YAML Simulation File You need a [YAML simulation file](/docs/DeviceSimulation.md) for your device. @@ -173,3 +176,11 @@ pass: - 'hash-mgmt-user oxidized password hash ' - 'hash-mgmt-user rocks password hash usertype read-only' ``` + +## Custom tests +When you write custom tests for your models, please do not use the filenames +mentioned above, as it will interfere with the standard tests. If you need to +store a custom simulation file, use `model:description:custom_simulation.yaml`. + +The [cumulus test](/spec/model/cumulus_spec.rb) is an example of a custom +test. diff --git a/spec/model/cumulus_spec.rb b/spec/model/cumulus_spec.rb index 04e618c0c..9a84eef1c 100644 --- a/spec/model/cumulus_spec.rb +++ b/spec/model/cumulus_spec.rb @@ -12,7 +12,7 @@ model: 'cumulus', vars: { cumulus_use_nvue: true }) - model = YAML.load_file('spec/model/data/cumulus:MSN2010_5.9.2_nvue:simulation.yaml') + model = YAML.load_file('spec/model/data/cumulus:MSN2010_5.9.2_nvue:custom_simulation.yaml') mockmodel = MockSsh.new(model) Net::SSH.stubs(:start).returns mockmodel @@ -32,7 +32,7 @@ vars: { cumulus_routing_daemon: 'frr', enable: true }) - model = YAML.load_file('spec/model/data/cumulus:VX_5.4.0_frr:simulation.yaml') + model = YAML.load_file('spec/model/data/cumulus:VX_5.4.0_frr:custom_simulation.yaml') mockmodel = MockSsh.new(model) Net::SSH.stubs(:start).returns mockmodel diff --git a/spec/model/data/cumulus:MSN2010_5.9.2_nvue:simulation.yaml b/spec/model/data/cumulus:MSN2010_5.9.2_nvue:custom_simulation.yaml similarity index 100% rename from spec/model/data/cumulus:MSN2010_5.9.2_nvue:simulation.yaml rename to spec/model/data/cumulus:MSN2010_5.9.2_nvue:custom_simulation.yaml diff --git a/spec/model/data/cumulus:VX_5.4.0_frr:simulation.yaml b/spec/model/data/cumulus:VX_5.4.0_frr:custom_simulation.yaml similarity index 100% rename from spec/model/data/cumulus:VX_5.4.0_frr:simulation.yaml rename to spec/model/data/cumulus:VX_5.4.0_frr:custom_simulation.yaml