Skip to content
  • Alex Clemmer's avatar
    Test all branches of GH URI-parsing code · d54aeb39
    Alex Clemmer authored
    When a user adds a registry (e.g., through a command like `ks registry
    add`, or implicitly through `ks init`) we must parse a URI pointing at
    registry hosted on github.com, since we currently only support the
    `"github"` protocol.
    
    This logic is somewhat complex, since we must
    
      1. infer the location of a `registry.yaml` file given the URI, and
      2. accept and parse a broad set of URIs a user might provide.
    
    For example, consider the following valid URIs, and what we do to infer
    the location of the `registry.yaml` file that specifies a registry:
    
      URIs with an explicit `registry.yaml`:
        github.com/exampleOrg/exampleRepo/blob/master/registry.yaml
        github.com/exampleOrg/exampleRepo/blob/master/incubator/registry.yaml
    
      URIs with an implicit `registry.yaml`:
        github.com/exampleOrg/exampleRepo/
        github.com/exampleOrg/exampleRepo/tree/master
    
      URIs with different protocols (or no protocol specified)
        github.com/exampleOrg/exampleRepo
        http://github.com/exampleOrg/exampleRepo
        https://github.com/exampleOrg/exampleRepo
    
    
        www.github.com/exampleOrg/exampleRepo
    
    And so on.
    
    Because this parsing logic has many branches, it is important for us to
    test every branch, so that the user is not surprised when a command like
    `registry add` doesn't work.
    
    This commit will introduce such tests.
    
    Signed-off-by: default avatarAlex Clemmer <clemmer.alexander@gmail.com>
    d54aeb39