-
Notifications
You must be signed in to change notification settings - Fork 258
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a0214a3
commit 71acc1d
Showing
11 changed files
with
68 additions
and
59 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
[package] | ||
name = "tailcall-version" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
[dependencies] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
const DEFAULT_VERSION: &str = "0.1.0-dev"; | ||
|
||
pub struct Version { | ||
version: &'static str, | ||
} | ||
|
||
impl Version { | ||
pub const fn new(version: &'static str) -> Self { | ||
Version { version } | ||
} | ||
|
||
pub const fn as_str(&self) -> &'static str { | ||
self.version | ||
} | ||
|
||
pub fn is_dev(&self) -> bool { | ||
self.version.contains("dev") | ||
} | ||
} | ||
|
||
pub const VERSION: Version = match option_env!("APP_VERSION") { | ||
Some(version) => Version::new(version), | ||
None => Version::new(DEFAULT_VERSION), | ||
}; | ||
|
||
#[cfg(test)] | ||
mod tests { | ||
use super::*; | ||
|
||
#[test] | ||
fn test_default_version() { | ||
assert_eq!(VERSION.as_str(), DEFAULT_VERSION); | ||
assert!(VERSION.is_dev()); | ||
} | ||
|
||
#[test] | ||
fn test_custom_version() { | ||
const CUSTOM_VERSION: Version = Version::new("1.0.0-release"); | ||
assert_eq!(CUSTOM_VERSION.as_str(), "1.0.0-release"); | ||
assert!(!CUSTOM_VERSION.is_dev()); | ||
} | ||
} |