• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

endoze / nysm / 15221700177

24 May 2025 12:51AM UTC coverage: 93.269% (-2.1%) from 95.402%
15221700177

push

github

web-flow
Merge pull request #10 from endoze/feat-add-support-for-creating-secrets

Feat: Add support for creating secrets

14 of 16 new or added lines in 1 file covered. (87.5%)

2 existing lines in 2 files now uncovered.

97 of 104 relevant lines covered (93.27%)

1.68 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

75.0
/src/error.rs
1
#![deny(missing_docs)]
2
#[derive(thiserror::Error, Debug)]
3
#[repr(u8)]
4
/// Enum to define all of the possible errors that can occur during normal
5
/// use of Nysm.
6
pub enum NysmError {
7
  /// Error occurs when attempting to parse data as Json fails.
8
  #[error("Unable to parse data as json")]
9
  SerdeJson(#[from] serde_json::Error),
10

11
  /// Error occurs when attempting to parse data as Text fails.
12
  #[error("Unable to parse data as yaml")]
13
  SerdeYaml(#[from] serde_yml::Error),
14

15
  /// Error occurs when pretty printing the contents of a secret fails.
16
  #[error("Unable to pretty print data")]
17
  BatPrint(#[from] bat::error::Error),
18

19
  /// Error occurs when reading/writing a temporary file for secret
20
  /// editing fails.
21
  #[error("Unable to read/write file caused by: {}", .0)]
22
  IO(#[from] std::io::Error),
23

24
  /// Error occurs when retrieving a list of secrets from a provider fails.
25
  #[error("Unable to retrieve list of secrets from aws response")]
26
  AwsListSecretsNoList,
27

28
  /// Error occurs when a specific secret has no string value.
29
  #[error("Unable to retrieve string value from aws response")]
30
  AwsSecretValueNoValueString,
31

32
  /// Error occurs when updating a secret's string value fails
33
  #[error("Unable to update secret value")]
34
  AwsSecretValueUpdate,
35

36
  /// Error occurs when creating a secret fails
37
  #[error("Unable to create secret")]
38
  AwsSecretValueCreate,
39
}
40

41
impl PartialEq for NysmError {
1✔
42
  fn eq(&self, other: &Self) -> bool {
2✔
43
    std::mem::discriminant(self) == std::mem::discriminant(other)
1✔
44
  }
45
}
46

47
#[cfg(not(tarpaulin_include))]
UNCOV
48
#[cfg(test)]
×
49
mod tests {
50
  use super::*;
51
  use serde::de::Error;
52

53
  #[test]
54
  fn test_serde_json_error() {
55
    let error = NysmError::SerdeJson(serde_json::Error::custom("custom error"));
56
    assert_eq!(error.to_string(), "Unable to parse data as json");
57
  }
58

59
  #[test]
60
  fn test_serde_yaml_error() {
61
    let error = NysmError::SerdeYaml(serde_yml::Error::custom("custom error"));
62
    assert_eq!(error.to_string(), "Unable to parse data as yaml");
63
  }
64

65
  #[test]
66
  fn test_bat_print_error() {
67
    let error = NysmError::BatPrint(Into::<bat::error::Error>::into("custom error"));
68
    assert_eq!(error.to_string(), "Unable to pretty print data");
69
  }
70

71
  #[test]
72
  fn test_io_error() {
73
    let error = NysmError::IO(std::io::Error::new(
74
      std::io::ErrorKind::Other,
75
      "custom error",
76
    ));
77
    assert_eq!(
78
      error.to_string(),
79
      "Unable to read/write file caused by: custom error"
80
    );
81
  }
82

83
  #[test]
84
  fn test_aws_list_secrets_no_list_error() {
85
    let error = NysmError::AwsListSecretsNoList;
86
    assert_eq!(
87
      error.to_string(),
88
      "Unable to retrieve list of secrets from aws response"
89
    );
90
  }
91

92
  #[test]
93
  fn test_aws_secret_value_no_value_string_error() {
94
    let error = NysmError::AwsSecretValueNoValueString;
95
    assert_eq!(
96
      error.to_string(),
97
      "Unable to retrieve string value from aws response"
98
    );
99
  }
100

101
  #[test]
102
  fn test_aws_secret_value_update_error() {
103
    let error = NysmError::AwsSecretValueUpdate;
104
    assert_eq!(error.to_string(), "Unable to update secret value");
105
  }
106

107
  #[test]
108
  fn test_aws_secret_value_create_error() {
109
    let error = NysmError::AwsSecretValueCreate;
110
    assert_eq!(error.to_string(), "Unable to create secret");
111
  }
112

113
  #[test]
114
  fn test_partial_eq() {
115
    let error1 = NysmError::SerdeJson(serde_json::Error::custom("custom error"));
116
    let error2 = NysmError::SerdeJson(serde_json::Error::custom("custom error"));
117
    let error3 = NysmError::SerdeYaml(serde_yml::Error::custom("different error"));
118

119
    assert_eq!(error1, error2);
120
    assert_ne!(error1, error3);
121
  }
122
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc