test: add tests for bare spdx license header content (#92)

diff --git a/test/content_test.go b/test/content_test.go
new file mode 100644
index 0000000..0c69cf3
--- /dev/null
+++ b/test/content_test.go
@@ -0,0 +1,97 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package test
+
+import (
+	"io/ioutil"
+	"path/filepath"
+	"strings"
+	"testing"
+
+	"github.com/apache/skywalking-eyes/pkg/header"
+	"gopkg.in/yaml.v3"
+)
+
+var c struct {
+	Header header.ConfigHeader `yaml:"header"`
+}
+
+func init() {
+	content, err := ioutil.ReadFile("testdata/test-spdx-content.yaml")
+
+	if err != nil {
+		panic(err)
+	}
+	if err := yaml.Unmarshal(content, &c); err != nil {
+		panic(err)
+	}
+	if err := c.Header.Finalize(); err != nil {
+		panic(err)
+	}
+}
+
+func TestCheckFile(t *testing.T) {
+	type args struct {
+		name       string
+		file       string
+		result     *header.Result
+		wantErr    bool
+		hasFailure bool
+	}
+
+	tests := func() []args {
+		files, err := filepath.Glob("testdata/spdx_content_test/*")
+		if err != nil {
+			t.Error(err)
+		}
+
+		var cases []args
+
+		for _, file := range files {
+			cases = append(cases, args{
+				name:       file,
+				file:       file,
+				result:     &header.Result{},
+				wantErr:    false,
+				hasFailure: false,
+			})
+		}
+
+		return cases
+	}()
+
+	if len(tests) == 0 {
+		t.Errorf("Tests should not be empty")
+	}
+
+	for _, tt := range tests {
+		t.Run(tt.name, func(t *testing.T) {
+			if strings.TrimSpace(c.Header.GetLicenseContent()) == "" {
+				t.Errorf("License should not be empty")
+			}
+			if err := header.CheckFile(tt.file, &c.Header, tt.result); (err != nil) != tt.wantErr {
+				t.Errorf("CheckFile() error = %v, wantErr %v", err, tt.wantErr)
+			}
+			if len(tt.result.Ignored) > 0 {
+				t.Errorf("Should not ignore any file, %v", tt.result.Ignored)
+			}
+			if tt.result.HasFailure() != tt.hasFailure {
+				t.Errorf("CheckFile() result has failure = %v, wanted = %v", tt.result.Failure, tt.hasFailure)
+			}
+		})
+	}
+}
diff --git a/test/testdata/spdx_content_test/testcase.go b/test/testdata/spdx_content_test/testcase.go
new file mode 100644
index 0000000..6f8ec8f
--- /dev/null
+++ b/test/testdata/spdx_content_test/testcase.go
@@ -0,0 +1,3 @@
+// SPDX-License-Identifier: Apache-2.0
+
+package withlicense
diff --git a/test/testdata/spdx_content_test/testcase.graphql b/test/testdata/spdx_content_test/testcase.graphql
new file mode 100644
index 0000000..9881313
--- /dev/null
+++ b/test/testdata/spdx_content_test/testcase.graphql
@@ -0,0 +1 @@
+# SPDX-License-Identifier: Apache-2.0
diff --git a/test/testdata/spdx_content_test/testcase.ini b/test/testdata/spdx_content_test/testcase.ini
new file mode 100644
index 0000000..c8ad870
--- /dev/null
+++ b/test/testdata/spdx_content_test/testcase.ini
@@ -0,0 +1,3 @@
+; SPDX-License-Identifier: Apache-2.0
+
+; program config file
diff --git a/test/testdata/spdx_content_test/testcase.java b/test/testdata/spdx_content_test/testcase.java
new file mode 100644
index 0000000..07bcd42
--- /dev/null
+++ b/test/testdata/spdx_content_test/testcase.java
@@ -0,0 +1,3 @@
+/**
+ * SPDX-License-Identifier: Apache-2.0
+ */
diff --git a/test/testdata/spdx_content_test/testcase.ml b/test/testdata/spdx_content_test/testcase.ml
new file mode 100644
index 0000000..17ae1cc
--- /dev/null
+++ b/test/testdata/spdx_content_test/testcase.ml
@@ -0,0 +1,3 @@
+(* SPDX-License-Identifier: Apache-2.0
+
+let to_string = function Left -> "Left" | Non -> "Non" | Right -> "Right"
diff --git a/test/testdata/spdx_content_test/testcase.php b/test/testdata/spdx_content_test/testcase.php
new file mode 100644
index 0000000..714e01b
--- /dev/null
+++ b/test/testdata/spdx_content_test/testcase.php
@@ -0,0 +1,4 @@
+<?php declare(strict_types=1);
+/*
+ * SPDX-License-Identifier: Apache-2.0
+ */
diff --git a/test/testdata/spdx_content_test/testcase.pl b/test/testdata/spdx_content_test/testcase.pl
new file mode 100644
index 0000000..644282c
--- /dev/null
+++ b/test/testdata/spdx_content_test/testcase.pl
@@ -0,0 +1,2 @@
+#!/usr/bin/env perl
+# SPDX-License-Identifier: Apache-2.0
diff --git a/test/testdata/spdx_content_test/testcase.py b/test/testdata/spdx_content_test/testcase.py
new file mode 100644
index 0000000..9881313
--- /dev/null
+++ b/test/testdata/spdx_content_test/testcase.py
@@ -0,0 +1 @@
+# SPDX-License-Identifier: Apache-2.0
diff --git a/test/testdata/spdx_content_test/testcase.pyx b/test/testdata/spdx_content_test/testcase.pyx
new file mode 100644
index 0000000..9881313
--- /dev/null
+++ b/test/testdata/spdx_content_test/testcase.pyx
@@ -0,0 +1 @@
+# SPDX-License-Identifier: Apache-2.0
diff --git a/test/testdata/spdx_content_test/testcase.sh b/test/testdata/spdx_content_test/testcase.sh
new file mode 100644
index 0000000..5361444
--- /dev/null
+++ b/test/testdata/spdx_content_test/testcase.sh
@@ -0,0 +1,2 @@
+#! /bin/bash
+# SPDX-License-Identifier: Apache-2.0
diff --git a/test/testdata/spdx_content_test/testcase.yaml b/test/testdata/spdx_content_test/testcase.yaml
new file mode 100644
index 0000000..9881313
--- /dev/null
+++ b/test/testdata/spdx_content_test/testcase.yaml
@@ -0,0 +1 @@
+# SPDX-License-Identifier: Apache-2.0
diff --git a/test/testdata/spdx_content_test/testcase.yml b/test/testdata/spdx_content_test/testcase.yml
new file mode 100644
index 0000000..9881313
--- /dev/null
+++ b/test/testdata/spdx_content_test/testcase.yml
@@ -0,0 +1 @@
+# SPDX-License-Identifier: Apache-2.0
diff --git a/test/testdata/test-spdx-content.yaml b/test/testdata/test-spdx-content.yaml
new file mode 100644
index 0000000..081adc4
--- /dev/null
+++ b/test/testdata/test-spdx-content.yaml
@@ -0,0 +1,4 @@
+header:
+  license:
+    content: |
+      SPDX-License-Identifier: Apache-2.0