防止在测试时更改结构指针值

我如何防止对结构值所做的任何更改仅保留在子测试中,即保持它们在子测试之外不受影响。我无法对结构进行任何更改,因为它们是使用swagger代码生成的自动生成的。这是一个例子:

package main

import (
    "testing"
)

func TestTyre(t *testing.T) {
    type Tyre struct {
        Color *string
    }
    type Vehicle struct {
        Tyre Tyre
    }

    color := "black"
    tyreForTest := Tyre{Color: &color}
    expectedTyreColor := color

    t.Run("negativeTest", func(t *testing.T) {
        tyre := tyreForTest               // would have worked if there weren't any pointer variables
        *tyre.Color = "blue"              // here I expect value to change only for this subtest

        vehicle := Vehicle{Tyre: tyre}
        actualTyreColor := vehicle.Tyre.Color

        ok := (expectedTyreColor == *actualTyreColor)
        if ok {
            t.Error("Color should be blue")
        }
    })
    t.Run("positiveTest", func(t *testing.T) {
        tyre := tyreForTest

        vehicle := Vehicle{Tyre: tyre}
        actualTyreColor := vehicle.Tyre.Color

        ok := (expectedTyreColor == *actualTyreColor)
        if !ok {
            t.Error("Color should be black, instead of", *actualTyreColor)
        }
    })
}

输出:

=== RUN   TestTyre
=== RUN   TestTyre/negativeTest
=== RUN   TestTyre/positiveTest
    TestTyre/positiveTest: prog.go:39: Color should be black, instead of blue
--- FAIL: TestTyre (0.00s)
    --- PASS: TestTyre/negativeTest (0.00s)
    --- FAIL: TestTyre/positiveTest (0.00s)
FAIL