Skip to content
Snippets Groups Projects
Unverified Commit 28b0e3c5 authored by Noah Moss's avatar Noah Moss Committed by GitHub
Browse files

Fix logic for deployment-model in stats ping (#49260)

parent 32f9d0f2
No related branches found
No related tags found
No related merge requests found
......@@ -516,10 +516,10 @@
(defn- deployment-model
[]
(case
(premium-features/is-hosted?) "cloud"
(in-docker?) "docker"
:else "jar"))
(cond
(premium-features/is-hosted?) "cloud"
(in-docker?) "docker"
:else "jar"))
(def ^:private activation-days 3)
......
(ns metabase.analytics.stats-test
(:require
[clojure.java.io :as io]
[clojure.set :as set]
[clojure.test :refer :all]
[java-time.api :as t]
......@@ -423,6 +424,23 @@
config/current-minor-version (constantly nil)]
(is false? (@#'stats/csv-upload-available?))))))
(deftest deployment-model-test
(testing "deployment model correctly reports cloud/docker/jar"
(with-redefs [premium-features/is-hosted? (constantly true)]
(is (= "cloud" (@#'stats/deployment-model))))
;; Lets just mock io/file to always return an existing (temp) file, to validate that we're doing a filesystem check
;; to determine whether we're in a Docker container
(mt/with-temp-file [mock-file]
(spit mock-file "Temp file!")
(with-redefs [premium-features/is-hosted? (constantly false)
io/file (constantly (java.io.File. mock-file))]
(is (= "docker" (@#'stats/deployment-model)))))
(with-redefs [premium-features/is-hosted? (constantly false)
stats/in-docker? (constantly false)]
(is (= "jar" (@#'stats/deployment-model))))))
(deftest no-features-enabled-but-not-available-test
(testing "Ensure that a feature cannot be reported as enabled if it is not also available"
;; Clear premium features so (most of) the features are considered unavailable
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment