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

endoze / nysm / 15228498341

24 May 2025 03:30PM UTC coverage: 92.523% (-0.7%) from 93.269%
15228498341

push

github

web-flow
Merge pull request #20 from endoze/feat-add-support-for-deleting-secrets

Feat: Add support for deleting secrets

3 of 3 new or added lines in 1 file covered. (100.0%)

1 existing line in 1 file now uncovered.

99 of 107 relevant lines covered (92.52%)

1.69 hits per line

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

50.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
  /// Error occurs when deleting a secret fails
41
  #[error("Unable to delete secret")]
42
  AwsSecretValueDelete,
43
}
44

UNCOV
45
impl PartialEq for NysmError {
×
46
  fn eq(&self, other: &Self) -> bool {
1✔
47
    std::mem::discriminant(self) == std::mem::discriminant(other)
1✔
48
  }
49
}
50

51
#[cfg(not(tarpaulin_include))]
52
#[cfg(test)]
×
53
mod tests {
54
  use super::*;
55
  use serde::de::Error;
56

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

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

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

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

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

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

105
  #[test]
106
  fn test_aws_secret_value_update_error() {
107
    let error = NysmError::AwsSecretValueUpdate;
108
    assert_eq!(error.to_string(), "Unable to update secret value");
109
  }
110

111
  #[test]
112
  fn test_aws_secret_value_create_error() {
113
    let error = NysmError::AwsSecretValueCreate;
114
    assert_eq!(error.to_string(), "Unable to create secret");
115
  }
116

117
  #[test]
118
  fn test_aws_secret_value_delete_error() {
119
    let error = NysmError::AwsSecretValueDelete;
120
    assert_eq!(error.to_string(), "Unable to delete secret");
121
  }
122

123
  #[test]
124
  fn test_partial_eq() {
125
    let error1 = NysmError::SerdeJson(serde_json::Error::custom("custom error"));
126
    let error2 = NysmError::SerdeJson(serde_json::Error::custom("custom error"));
127
    let error3 = NysmError::SerdeYaml(serde_yml::Error::custom("different error"));
128

129
    assert_eq!(error1, error2);
130
    assert_ne!(error1, error3);
131
  }
132
}
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