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

Testenv test refactor #221

Merged
merged 11 commits into from
Nov 11, 2021
Merged

Commits on Nov 11, 2021

  1. Add testenv TestMain and move ginkgo to legacy

    Add new testenv based TestMain in suite_test.go and move the ginkgo test
    setup to legacy_suite_test.go. This helps to run both the ginkgo tests
    and testenv based tests.
    
    Signed-off-by: Sunny <darkowlzz@protonmail.com>
    darkowlzz committed Nov 11, 2021
    Configuration menu
    Copy the full SHA
    31b304d View commit details
    Browse the repository at this point in the history
  2. controllers/update_test.go: Update to use testenv

    Signed-off-by: Sunny <darkowlzz@protonmail.com>
    darkowlzz committed Nov 11, 2021
    Configuration menu
    Copy the full SHA
    3b131ba View commit details
    Browse the repository at this point in the history
  3. update pkg/test and pkg/update with testenv

    Signed-off-by: Sunny <darkowlzz@protonmail.com>
    darkowlzz committed Nov 11, 2021
    Configuration menu
    Copy the full SHA
    3a03fad View commit details
    Browse the repository at this point in the history
  4. Remove legacy_suite_test.go

    All the tests use testenv. Remove legacy envtest suite_test.
    
    Signed-off-by: Sunny <darkowlzz@protonmail.com>
    darkowlzz committed Nov 11, 2021
    Configuration menu
    Copy the full SHA
    11dfea5 View commit details
    Browse the repository at this point in the history
  5. Update tests to be compatible with CR > v0.10.0

    In controller-runtime v0.10.0, the client is updated to clean any stale
    data in the target object when performing any operation. This results in
    test failure for the code that constructs an object with both spec and
    status, and creates the object and updates status it with the same
    object. The fix is to set the status separately on the object before
    updating it.
    
    Refer: kubernetes-sigs/controller-runtime#1640
    
    Signed-off-by: Sunny <darkowlzz@protonmail.com>
    darkowlzz committed Nov 11, 2021
    Configuration menu
    Copy the full SHA
    f415d86 View commit details
    Browse the repository at this point in the history
  6. Correct directory diffing test and algorithm

    Two steps:
    
    1. TestDiffDirectories did not check if the expected only return value
    was correct; the intention was there to do so (judging by the
    comment "change in order"), but my eye for detail failed me.
    
    2. Reversing the directory comparison in the test revealed bugs in the
    comparison code -- in general, it should skip any directory that is
    not a directory in the comparator.
    
    To make this easier, the code now keeps track of the expected files it
    saw. That means the check for whether an actual file has an expected
    counterpart only has two cases, yes or no (rather that trying to
    account for whether it's a directory and so on). If a directory was
    skipped while scanning the expected files, it won't be in the actual
    files anyway.
    
    Signed-off-by: Michael Bridgen <michael@weave.works>
    squaremo authored and darkowlzz committed Nov 11, 2021
    Configuration menu
    Copy the full SHA
    8a36a79 View commit details
    Browse the repository at this point in the history
  7. Restructure tests in update_test.go

    Restructures the tests in update_test.go to separate the individual
    checks into separate tests with helpers for common operations.
    
    Signed-off-by: Sunny <darkowlzz@protonmail.com>
    darkowlzz committed Nov 11, 2021
    Configuration menu
    Copy the full SHA
    b8c9f43 View commit details
    Browse the repository at this point in the history
  8. Add testWithRepoAndImagePolicy() in update_test.go

    testWithRepoAndImagePolicy() contains common code to create a git
    server, git repository and ImagePolicy for the test setup.
    Also updates some test structure slightly.
    
    Signed-off-by: Sunny <darkowlzz@protonmail.com>
    darkowlzz committed Nov 11, 2021
    Configuration menu
    Copy the full SHA
    5ae1d28 View commit details
    Browse the repository at this point in the history
  9. Reduce higher-order function in test template

    This is just a cosmetic thing -- there's no need for the higher-order
    func used to create mini test suites, given the protocol and git
    implementation. This made the Gingko version clearer, arguably, but it
    can be reduced away here for a bit less nesting.
    
    Signed-off-by: Michael Bridgen <michael@weave.works>
    squaremo authored and darkowlzz committed Nov 11, 2021
    Configuration menu
    Copy the full SHA
    f4b89bd View commit details
    Browse the repository at this point in the history
  10. Collect test args into struct

    This tidies the random string testWithRepoAndImagePolicy() arguments
    into a struct, which reduces clutter (and the chance of getting them
    in the wrong order) in invocations.
    
    Signed-off-by: Michael Bridgen <michael@weave.works>
    squaremo authored and darkowlzz committed Nov 11, 2021
    Configuration menu
    Copy the full SHA
    dd81020 View commit details
    Browse the repository at this point in the history
  11. update_test: Create ImagePolicy per subtest

    In TestImageUpdateAutomation_e2e, move the ImagePolicy to be created per
    subtest and not shared in the common test environment. This makes the
    tests more independent of each other.
    
    Signed-off-by: Sunny <darkowlzz@protonmail.com>
    darkowlzz committed Nov 11, 2021
    Configuration menu
    Copy the full SHA
    8b96c15 View commit details
    Browse the repository at this point in the history