From c1111a1d2d7720cbf0087b384eeb29d5c3fee31c Mon Sep 17 00:00:00 2001 From: "James O. D. Hunt" Date: Tue, 23 Nov 2021 09:56:27 +0000 Subject: [PATCH] docs: Use leading caps for lang names in UT advice doc Use a capital letter when referring to Golang and Rust (and remove unnecessary backticks for Rust). > **Note:** > > We continue refer to "Go" as "Golang" since it's a common alias, > but, crucially, familiarity with this name makes searching for > information using this term possible: "Go" is too generic a word. Signed-off-by: James O. D. Hunt --- docs/Unit-Test-Advice.md | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/docs/Unit-Test-Advice.md b/docs/Unit-Test-Advice.md index 8bdbfd4c66..f4231dff7a 100644 --- a/docs/Unit-Test-Advice.md +++ b/docs/Unit-Test-Advice.md @@ -3,11 +3,11 @@ ## Overview This document offers advice on writing a Unit Test (UT) in -[`golang`](https://golang.org) and [`rust`](https://www.rust-lang.org). +[Golang](https://golang.org) and [Rust](https://www.rust-lang.org). ## Assertions -### golang assertions +### Golang assertions Use the `testify` assertions package to create a new assertion object as this keeps the test code free from distracting `if` tests: @@ -21,7 +21,7 @@ func TestSomething(t *testing.T) { } ``` -### rust assertions +### Rust assertions Use the standard set of `assert!()` macros. @@ -32,7 +32,7 @@ the logic into a compact table (rather than spreading the tests across multiple test functions). It also makes it easy to cover all the interesting boundary conditions: -### golang table driven tests +### Golang table driven tests Assume the following function: @@ -113,7 +113,7 @@ func TestJoinParamsWithDash(t *testing.T) { } ``` -### rust table driven tests +### Rust table driven tests Assume the following function: @@ -216,7 +216,7 @@ mod tests { Always delete temporary files on success. -### golang temporary files +### Golang temporary files ```go func TestSomething(t *testing.T) { @@ -233,7 +233,7 @@ func TestSomething(t *testing.T) { } ``` -### rust temporary files +### Rust temporary files Use the `tempfile` crate which allows files and directories to be deleted automatically: @@ -273,13 +273,13 @@ Some repositories already provide utility functions to skip a test: - if running as `root` - if not running as `root` -### running golang tests as different users +### running Golang tests as a different user The runtime repository has the most comprehensive set of skip abilities. See: - https://github.com/kata-containers/kata-containers/tree/main/src/runtime/pkg/katatestutils -### running rust tests as different users +### running Rust tests as a different user One method is to use the `nix` crate along with some custom macros: