@@ -52,3 +52,79 @@ func TestViewOptions(t *testing.T) {
5252 t .Errorf ("unexpected Package %q" , opts .Package )
5353 }
5454}
55+
56+ func TestViewOptionsAllFields (t * testing.T ) {
57+ opts := ViewOptions {
58+ ProjectRoot : "/home/user/project" ,
59+ Package : "owner/repo" ,
60+ Field : "versions" ,
61+ Format : "json" ,
62+ Verbose : true ,
63+ }
64+ if opts .ProjectRoot != "/home/user/project" {
65+ t .Errorf ("ProjectRoot mismatch: %q" , opts .ProjectRoot )
66+ }
67+ if opts .Field != "versions" {
68+ t .Errorf ("Field mismatch: %q" , opts .Field )
69+ }
70+ if ! opts .Verbose {
71+ t .Error ("Verbose should be true" )
72+ }
73+ }
74+
75+ func TestParseSimpleYAMLMultipleValues (t * testing.T ) {
76+ data := []byte ("key1: val1\n key2: val2\n key3: val3\n " )
77+ var out map [string ]interface {}
78+ if err := parseSimpleYAML (data , & out ); err != nil {
79+ t .Fatalf ("unexpected error: %v" , err )
80+ }
81+ if len (out ) != 3 {
82+ t .Errorf ("expected 3 entries, got %d" , len (out ))
83+ }
84+ if out ["key3" ] != "val3" {
85+ t .Errorf ("key3 = %v, want %q" , out ["key3" ], "val3" )
86+ }
87+ }
88+
89+ func TestParseSimpleYAMLColonInValue (t * testing.T ) {
90+ data := []byte ("url: https://example.com\n " )
91+ var out map [string ]interface {}
92+ if err := parseSimpleYAML (data , & out ); err != nil {
93+ t .Fatalf ("unexpected error: %v" , err )
94+ }
95+ if out ["url" ] != "https://example.com" {
96+ t .Errorf ("url = %v, want %q" , out ["url" ], "https://example.com" )
97+ }
98+ }
99+
100+ func TestParseSimpleYAMLOnlyComments (t * testing.T ) {
101+ data := []byte ("# this is a comment\n # another comment\n " )
102+ var out map [string ]interface {}
103+ if err := parseSimpleYAML (data , & out ); err != nil {
104+ t .Fatalf ("unexpected error: %v" , err )
105+ }
106+ if len (out ) != 0 {
107+ t .Errorf ("expected empty map for comment-only input, got %v" , out )
108+ }
109+ }
110+
111+ func TestPackageInfoFields (t * testing.T ) {
112+ info := PackageInfo {
113+ Name : "my-pkg" ,
114+ InstalledPath : "/path/to/.apm_modules/my-pkg" ,
115+ Ref : "v1.2.3" ,
116+ Commit : "deadbeef" ,
117+ Source : "https://github.com/owner/my-pkg" ,
118+ Files : []string {"SKILL.md" , "apm.yml" },
119+ Versions : []string {"v1.0.0" , "v1.2.3" },
120+ }
121+ if info .Name != "my-pkg" {
122+ t .Errorf ("Name mismatch: %q" , info .Name )
123+ }
124+ if len (info .Files ) != 2 {
125+ t .Errorf ("Files length: got %d, want 2" , len (info .Files ))
126+ }
127+ if info .Versions [1 ] != "v1.2.3" {
128+ t .Errorf ("Versions[1]: got %q, want %q" , info .Versions [1 ], "v1.2.3" )
129+ }
130+ }
0 commit comments