Commit 35b85dde authored by 06kellyjac's avatar 06kellyjac
Browse files

stripe-cli: properly skip tests and fix for darwin sandbox

parent 6d17d94f
Loading
Loading
Loading
Loading
+26 −10
Original line number Diff line number Diff line
@@ -5,6 +5,8 @@
  installShellFiles,
  stdenv,

  writableTmpDirAsHomeHook,

  buildPackages,
}:

@@ -12,6 +14,9 @@ buildGoModule (finalAttrs: {
  pname = "stripe-cli";
  version = "1.31.0";

  # required for tests
  __darwinAllowLocalNetworking = true;

  src = fetchFromGitHub {
    owner = "stripe";
    repo = "stripe-cli";
@@ -28,34 +33,45 @@ buildGoModule (finalAttrs: {
    "-X github.com/stripe/stripe-cli/pkg/version.Version=${finalAttrs.version}"
  ];

  nativeCheckInputs = [
    # required by pkg/rpcservice/sample_create_test.go
    writableTmpDirAsHomeHook
  ];

  preCheck = ''
    # the tests expect the Version ldflag not to be set
    unset ldflags

    # requires internet access
    rm pkg/cmd/plugin_cmds_test.go
    rm pkg/cmd/resources_test.go
    rm pkg/cmd/root_test.go

    # TODO: no clue why it's broken (1.17.1), remove for now.
    rm pkg/login/client_login_test.go
    rm pkg/git/editor_test.go
    rm pkg/rpcservice/sample_create_test.go
  ''
  +
    lib.optionalString
      (
        # delete plugin tests on all platforms but exact matches
        # https://github.com/stripe/stripe-cli/issues/850
        # https://github.com/stripe/stripe-cli/blob/e3020d2e2df9c731b2f51df3aa53bf16383e863f/pkg/plugins/test_artifacts/plugins.toml
        !lib.lists.any (platform: lib.meta.platformMatch stdenv.hostPlatform platform) [
          "x86_64-linux"
          "x86_64-darwin"
          "aarch64-darwin"
        ]
      )
      ''
        rm pkg/plugins/plugin_test.go
      '';

  checkFlags =
    let
      skippedTests = [
        # network access
        "TestConflictWithPluginCommand"
        "TestLogin"

        # not providing git or the various editors it wants to call
        "TestGetOpenEditorCommand"
        "TestGetDefaultGitEditor"
      ];
    in
    [ "-skip=^${lib.concatStringsSep "$|^" skippedTests}$" ];

  postInstall =
    let
      inherit (finalAttrs.meta) mainProgram;